public void GivenASubscriberCallbackIsConfiguredToListenAtWithAPrefixOf(string callbackUrl, string prefix) { var subscriberCallback = new PushSubscriberCallback(prefix); subscriberCallback.PushVerify += (sender, args) => { _verifyWasCalled = true; args.Allow = true; }; subscriberCallback.PushPost += (sender, args) => { _updatedFeedContent = args.Feed; }; subscriberCallback.Start(); ScenarioContext.Current.Add("SubscriberCallback", subscriberCallback); ScenarioContext.Current.Add("SubscriberCallbackUrl", callbackUrl); }
static void Main(string[] args) { // So trace output will go to the console. Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); Debug.AutoFlush = true; var callback = new PushSubscriberCallback("http://+:8080/"); try { callback.Start(); callback.PushPost += callback_PushPost; callback.PushVerify += callback_PushVerify; // Subscribe to a feed Console.WriteLine("Subscribing to {0}", FeedToSubscribe); var statusCode = PuSHSubscriber.Subscribe( HubUrl, CallbackUrl, FeedToSubscribe, PushVerifyType.Sync, 0, "xyzzy", null); Console.WriteLine("Status code = " + statusCode); Console.WriteLine("Listening for connections from hub."); Console.WriteLine("Press Enter to exit program."); Console.ReadLine(); // Unsubscribe Console.WriteLine("Unsubscribing..."); statusCode = PuSHSubscriber.Unsubscribe( HubUrl, CallbackUrl, FeedToSubscribe, PushVerifyType.Sync, "xyzzy"); Console.WriteLine("Return value = " + statusCode); } finally { callback.Stop(); callback.Dispose(); } Debug.Flush(); }