static void subscribeChannels(pubnub pubnub) { foreach (string _channel in many_channels) { Thread t = new Thread(delegate() { Dictionary <String, Object> argsSub = new Dictionary <String, Object>(2); argsSub.Add("channel", _channel); argsSub.Add("callback", new Receiver()); // callback to get response // Listen for Messages (Subscribe) pubnub.Subscribe(argsSub); }); t.Start(); if (threads.ContainsKey(_channel)) { threads[_channel] = t; } else { threads.Add(_channel, t); } try { Thread.Sleep(1000); } catch (ThreadAbortException e) { Debug.WriteLine(e.Message); } } }
private void Subscribe_Click(object sender, RoutedEventArgs e) { lblSubscribe.Text = "Subscribe to the channel " + channel; pubnub.ResponseCallback respCallback = delegate(object message) { object[] messages = (object[])message; UIThread.Invoke(() => { if (messages != null && messages.Count() > 0) { subMessage.Visibility = Visibility.Visible; for (int i = 0; i < messages.Count(); i++) { if (!(lSubscribe.Items.Contains(messages[i].ToString()))) { lSubscribe.Items.Add(messages[i].ToString()); } } } }); }; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("channel", channel); args.Add("callback", respCallback); objPubnub.Subscribe(args); }
private void Subscribe_Click(object sender, RoutedEventArgs e) { lblSubscribe.Text = "Subscribe to the channel " + channel; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("channel", channel); args.Add("callback", new Receiver()); objPubnub.Subscribe(args); }
static public void test_subscribe() { // Initialize pubnub state pubnub objPubnub = new pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); //define channel string channel = "hello-world"; Dictionary <string, object> args = new Dictionary <string, object>(); args = new Dictionary <string, object>(); args.Add("channel", channel); args.Add("callback", new silverlight.Receiver()); // callback to get response objPubnub.Subscribe(args); }
static void subscribeChannels(pubnub pubnub) { foreach (string _channel in many_channels) { Thread t = new Thread(delegate() { Dictionary<String, Object> argsSub = new Dictionary<String, Object>(2); argsSub.Add("channel", _channel); argsSub.Add("callback", new Receiver()); // callback to get response // Listen for Messages (Subscribe) pubnub.Subscribe(argsSub); }); t.Start(); if (threads.ContainsKey(_channel)) threads[_channel] = t; else threads.Add(_channel, t); try { Thread.Sleep(1000); } catch (ThreadAbortException e) { Debug.WriteLine(e.Message); } } }
public static void test_subscribe() { // Initialize pubnub state pubnub objPubnub = new pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); //define channel string channel = "hello-world"; Dictionary<string, object> args = new Dictionary<string, object>(); args = new Dictionary<string, object>(); args.Add("channel", channel); args.Add("callback", new silverlight.Receiver()); // callback to get response objPubnub.Subscribe(args); }