static public void test_time() { // 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? ); // Get PubNub Server Time objPubnub.Time(timedelegate); }
static public void test_uuid() { // 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? ); //Get UUID string uuid = objPubnub.UUID(); Debug.WriteLine("Generated UUID - > - " + uuid); }
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); } } }
static void UnitTestAll(pubnub pubnub) { status.Clear(); threads.Clear(); many_channels.Clear(); if (runthroughs >= 2) { runthroughs = 0; } _pubnub = pubnub; if (!status.ContainsKey("sent")) status.Add("sent", 0); if (!status.ContainsKey("received")) status.Add("received", 0); if (!status.ContainsKey("connections")) status.Add("connections", 0); for (int i = 0; i < many_channels.Capacity; i++) { many_channels.Add("channel_" + i); channelConnected[many_channels[i]] = false; channelStatus[many_channels[i]] = status; } subscribeChannels(_pubnub); }
public static void test_uuid() { // 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? ); //Get UUID string uuid = objPubnub.UUID(); Debug.WriteLine("Generated UUID - > - " + uuid); }
public static void test_time() { // 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? ); // Get PubNub Server Time objPubnub.Time(timedelegate); }
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); }
public static void test_publish() { // 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"; pubnub.ResponseCallback respCallback = delegate(object response) { List<object> messages = (List<object>)response; if (messages != null && messages.Count > 0) { Debug.WriteLine("[" + messages[0] + " , " + messages[1] + "]"); } }; Dictionary<string, object> strArgs = new Dictionary<string, object>(); string message = "Hello Silverlight"; strArgs.Add("channel", channel); strArgs.Add("message", message); strArgs.Add("callback", respCallback); objPubnub.Publish(strArgs); }
public static void test_history() { pubnub.ResponseCallback histCallback = delegate(object response) { List<object> result = (List<object>)response; Debug.WriteLine("[History data]"); foreach (object data in result) { Debug.WriteLine(data); } }; // 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"; // History Dictionary<string, object> argsHist = new Dictionary<string, object>(); argsHist.Add("channel", channel); argsHist.Add("limit", 3.ToString()); argsHist.Add("callback", histCallback); objPubnub.History(argsHist); }