protected void Page_Load(object sender, EventArgs e) { // channel name string channel = "test-iis"; pubnub objPubnub = new pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); System.Diagnostics.Debug.WriteLine("Subscribe to channel " + channel); pubnub.Procedure callback = delegate(object message) { System.Diagnostics.Debug.WriteLine(message); return true; }; Dictionary<string, object> args = new Dictionary<string, object>(); args.Add("channel", channel); args.Add("callback", callback); // Subscribe to channel objPubnub.Subscribe(args); }
protected void Page_Load(object sender, EventArgs e) { // channel name string channel = "test-iis"; // 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? ); // History Dictionary<string, string> args = new Dictionary<string, string>(); args.Add("channel", channel); args.Add("limit", 3.ToString()); List<object> history = objPubnub.History(args); System.Diagnostics.Debug.WriteLine(""); System.Diagnostics.Debug.WriteLine("History messages - > "); foreach (object history_message in history) { System.Diagnostics.Debug.WriteLine(history_message); } }
protected void Page_Load(object sender, EventArgs e) { // channel name string channel = "test-iis"; // 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? ); List<object> info = null; Dictionary<string, object> args = new Dictionary<string, object>(); // Publish string message args.Add("channel", channel); args.Add("message", "Hello Csharp - IIS"); info = objPubnub.Publish(args); // Print Response Debug.WriteLine(" "); ; Debug.WriteLine("Published messages - >"); Debug.WriteLine("[ " + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); // Publish message in array format args = new Dictionary<string, object>(); JArray jarr = new JArray(); jarr.Add("Sunday"); jarr.Add("Monday"); jarr.Add("Tuesday"); jarr.Add("Wednesday"); jarr.Add("Thursday"); jarr.Add("Friday"); jarr.Add("Saturday"); args.Add("channel", channel); args.Add("message", jarr); info = objPubnub.Publish(args); // Print Response Debug.WriteLine("[ " + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); // Publish message in object(key - val) format args = new Dictionary<string, object>(); JObject jObj = new JObject(); jObj.Add("Name", "John"); jObj.Add("age", "25"); args.Add("channel", channel); args.Add("message", jObj); info = objPubnub.Publish(args); // Print Response Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); }
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"; //Subscribe messages pubnub.Procedure Receiver = delegate(object message) { Debug.WriteLine("Message - " + message); return(true); }; pubnub.Procedure ConnectCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; pubnub.Procedure DisconnectCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; pubnub.Procedure ReconnectCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; pubnub.Procedure ErrorCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; Dictionary <string, object> args = new Dictionary <string, object>(); args = new Dictionary <string, object>(); args.Add("channel", channel); args.Add("callback", Receiver); // callback to get response args.Add("connect_cb", ConnectCallback); // callback to get connect event args.Add("disconnect_cb", DisconnectCallback); // callback to get disconnect event args.Add("reconnect_cb", ReconnectCallback); // callback to get reconnect event args.Add("error_cb", ErrorCallback); // callback to get error event objPubnub.Subscribe(args); }
protected void Page_Load(object sender, EventArgs e) { // channel name string channel = "test-iis"; pubnub objPubnub = new pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); pubnub.Procedure Receiver = delegate(object message) { Debug.WriteLine(message); return(true); }; pubnub.Procedure ConnectCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; pubnub.Procedure DisconnectCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; pubnub.Procedure ReconnectCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; pubnub.Procedure ErrorCallback = delegate(object message) { Debug.WriteLine(message); return(true); }; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("channel", channel); args.Add("callback", Receiver); // callback to get response args.Add("connect_cb", ConnectCallback); // callback to get connect event args.Add("disconnect_cb", DisconnectCallback); // callback to get disconnect event args.Add("reconnect_cb", ReconnectCallback); // callback to get reconnect event args.Add("error_cb", ErrorCallback); // callback to get error event // Subscribe messages objPubnub.Subscribe(args); }
protected void Page_Load(object sender, EventArgs e) { // Initialize pubnub state pubnub objPubnub = new pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY false // SSL_ON? ); System.Diagnostics.Debug.WriteLine(""); System.Diagnostics.Debug.WriteLine("Server Time - > " + objPubnub.Time()); }
protected void Page_Load(object sender, EventArgs e) { // 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? ); Debug.WriteLine(""); Debug.WriteLine("Server Time - > " + objPubnub.Time()); }
protected void Page_Load(object sender, EventArgs e) { // Initialize pubnub state pubnub objPubnub = new pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "", // SECRET_KEY "", // CIPHER_KEY false // SSL_ON? ); Debug.WriteLine(""); Debug.WriteLine("Generated UUID - > " + objPubnub.UUID()); }
protected void Page_Load(object sender, EventArgs e) { // channel name string channel = "test-iis"; pubnub objPubnub = new pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); pubnub.Procedure Receiver = delegate(object message) { Debug.WriteLine(message); return true; }; pubnub.Procedure ConnectCallback = delegate(object message) { Debug.WriteLine(message); return true; }; pubnub.Procedure DisconnectCallback = delegate(object message) { Debug.WriteLine(message); return true; }; pubnub.Procedure ReconnectCallback = delegate(object message) { Debug.WriteLine(message); return true; }; pubnub.Procedure ErrorCallback = delegate(object message) { Debug.WriteLine(message); return true; }; Dictionary<string, object> args = new Dictionary<string, object>(); args.Add("channel", channel); args.Add("callback", Receiver); // callback to get response args.Add("connect_cb", ConnectCallback); // callback to get connect event args.Add("disconnect_cb", DisconnectCallback); // callback to get disconnect event args.Add("reconnect_cb", ReconnectCallback); // callback to get reconnect event args.Add("error_cb", ErrorCallback); // callback to get error event // Subscribe messages objPubnub.Subscribe(args); }
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 Debug.WriteLine(""); Debug.WriteLine("Generated UUID - > " + objPubnub.UUID()); }
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 Debug.WriteLine(""); Debug.WriteLine("Server Time - > " + objPubnub.Time()); }
static public 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"; List <object> info = null; Dictionary <string, object> args = new Dictionary <string, object>(); // Publish string message args.Add("channel", channel); args.Add("message", "Hello Csharp - IIS"); info = objPubnub.Publish(args); // Print response Debug.WriteLine(""); Debug.WriteLine("Published messages - >"); if (info != null) { if (info.Count == 3) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); } else if (info.Count == 2) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + "]"); } } else { Debug.WriteLine("Error in network connection"); } }
protected void Page_Load(object sender, EventArgs e) { // channel name string channel = "test-iis"; // 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? ); List <object> info = null; Dictionary <string, object> args = new Dictionary <string, object>(); // Publish string message args.Add("channel", channel); args.Add("message", "Hello Csharp - IIS"); info = objPubnub.Publish(args); // Print Response Debug.WriteLine(" ");; Debug.WriteLine("Published messages - >"); if (info != null) { if (info.Count == 3) //success { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); } else if (info.Count == 2) //error { Debug.WriteLine("[ " + info[0].ToString() + ", " + info[1] + "]"); } } else { Debug.WriteLine("Error in network connection"); } // Publish message in array format args = new Dictionary <string, object>(); JArray jarr = new JArray(); jarr.Add("Sunday"); jarr.Add("Monday"); jarr.Add("Tuesday"); jarr.Add("Wednesday"); jarr.Add("Thursday"); jarr.Add("Friday"); jarr.Add("Saturday"); args.Add("channel", channel); args.Add("message", jarr); info = objPubnub.Publish(args); // Print Response if (info != null) { if (info.Count == 3) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); } else if (info.Count == 2) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + "]"); } } else { Debug.WriteLine("Error in network connection"); } // Publish message in object(key - val) format args = new Dictionary <string, object>(); JObject jObj = new JObject(); jObj.Add("Name", "John"); jObj.Add("age", "25"); args.Add("channel", channel); args.Add("message", jObj); info = objPubnub.Publish(args); // Print Response if (info != null) { if (info.Count == 3) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); } else if (info.Count == 2) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + "]"); } } else { Debug.WriteLine("Error in network connection"); } }
static void UnitTestAll(pubnub pubnub) { status.Clear(); threads.Clear(); if (runthroughs >= 2) { runthroughs = 0; } _pubnub = pubnub; if (many_channels.Count <= 0) { for (int i = 0; i < many_channels.Capacity; i++) { many_channels.Add("channel_" + i); } } if (status.ContainsKey("sent")) status["sent"] = 0; else status.Add("sent", 0); if (status.ContainsKey("received")) status["received"] = 0; else status.Add("received", 0); if (status.ContainsKey("connections")) status["connections"] = 0; else status.Add("connections", 0); foreach (string _channel in many_channels) { ParameterizedThreadStart pts = new ParameterizedThreadStart(run); Thread t = new Thread(pts); t.Start(_channel); if (threads.ContainsKey(_channel)) threads[_channel] = t; else threads.Add(_channel, t); try { Thread.Sleep(1000); } catch (ThreadInterruptedException e) { Debug.WriteLine(e.Message); } } }
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 Debug.WriteLine(""); Debug.WriteLine("Generated UUID - > " + objPubnub.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 Debug.WriteLine(""); Debug.WriteLine("Server Time - > " + objPubnub.Time()); }
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"; //Subscribe messages pubnub.Procedure Receiver = delegate(object message) { Debug.WriteLine("Message - " + message); return true; }; pubnub.Procedure ConnectCallback = delegate(object message) { Debug.WriteLine(message); return true; }; pubnub.Procedure DisconnectCallback = delegate(object message) { Debug.WriteLine(message); return true; }; pubnub.Procedure ReconnectCallback = delegate(object message) { Debug.WriteLine(message); return true; }; pubnub.Procedure ErrorCallback = delegate(object message) { Debug.WriteLine(message); return true; }; Dictionary<string, object> args = new Dictionary<string, object>(); args = new Dictionary<string, object>(); args.Add("channel", channel); args.Add("callback", Receiver); // callback to get response args.Add("connect_cb", ConnectCallback); // callback to get connect event args.Add("disconnect_cb", DisconnectCallback); // callback to get disconnect event args.Add("reconnect_cb", ReconnectCallback); // callback to get reconnect event args.Add("error_cb", ErrorCallback); // callback to get error event 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"; List<object> info = null; Dictionary<string, object> args = new Dictionary<string, object>(); // Publish string message args.Add("channel", channel); args.Add("message", "Hello Csharp - IIS"); info = objPubnub.Publish(args); // Print response Debug.WriteLine(""); Debug.WriteLine("Published messages - >"); if (info != null) { if (info.Count == 3) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + ", " + info[2] + "]"); } else if (info.Count == 2) { Debug.WriteLine("[" + info[0].ToString() + ", " + info[1] + "]"); } } else { Debug.WriteLine("Error in network connection"); } }
public static void test_history() { // 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, string> args = new Dictionary<string, string>(); args.Add("channel", channel); args.Add("limit", 3.ToString()); List<object> history = objPubnub.History(args); Debug.WriteLine(""); Debug.WriteLine("History messages - > "); foreach (object history_message in history) { Debug.WriteLine(history_message); } }
static void UnitTestAll(pubnub pubnub) { status.Clear(); threads.Clear(); if (runthroughs >= 2) { runthroughs = 0; } _pubnub = pubnub; if (many_channels.Count <= 0) { for (int i = 0; i < many_channels.Capacity; i++) { many_channels.Add("channel_" + i); } } if (status.ContainsKey("sent")) { status["sent"] = 0; } else { status.Add("sent", 0); } if (status.ContainsKey("received")) { status["received"] = 0; } else { status.Add("received", 0); } if (status.ContainsKey("connections")) { status["connections"] = 0; } else { status.Add("connections", 0); } foreach (string _channel in many_channels) { ParameterizedThreadStart pts = new ParameterizedThreadStart(run); Thread t = new Thread(pts); t.Start(_channel); if (threads.ContainsKey(_channel)) { threads[_channel] = t; } else { threads.Add(_channel, t); } try { Thread.Sleep(1000); } catch (ThreadInterruptedException e) { Debug.WriteLine(e.Message); } } }