private void btnHistory_Click(object sender, RoutedEventArgs e) { //Channel name string channel = "hello_world"; // Initialize pubnub state Pubnub pubnub = new Pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); Pubnub.ResponseCallback respCallback = delegate(object response) { List <object> result = (List <object>)response; if (result != null && result.Count() > 0) { for (int i = 0; i < result.Count(); i++) { System.Diagnostics.Debug.WriteLine(result[i]); } } }; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("channel", channel); args.Add("limit", 3.ToString()); args.Add("callback", respCallback); pubnub.History(args); }
private void btnPublish_Click(object sender, RoutedEventArgs e) { //Channel name string channel = "hello_world"; // Initialize pubnub state Pubnub pubnub = new Pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); Pubnub.ResponseCallback respCallback = delegate(object response) { List <object> result = (List <object>)response; if (result != null && result.Count() > 0) { System.Diagnostics.Debug.WriteLine("[" + result[0].ToString() + "," + result[1].ToString() + "," + result[2].ToString() + "]"); } }; Dictionary <string, object> strArgs = new Dictionary <string, object>(); string message = "Hello Windows Phone 7"; strArgs.Add("channel", channel); strArgs.Add("message", message); strArgs.Add("callback", respCallback); pubnub.Publish(strArgs); Dictionary <string, object> arrArgs = 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"); arrArgs.Add("channel", channel); arrArgs.Add("message", jarr); arrArgs.Add("callback", respCallback); pubnub.Publish(arrArgs); Dictionary <string, object> objArgs = new Dictionary <string, object>(); JObject obj = new JObject(); obj.Add("Name", "Jhon"); obj.Add("age", "25"); objArgs.Add("channel", channel); objArgs.Add("message", obj); objArgs.Add("callback", respCallback); pubnub.Publish(objArgs); }
public static void publishAndSetStatus(string channel, object message) { Pubnub.ResponseCallback publishCallback = delegate(object response) { List <object> messages = (List <object>)response; if (messages != null && messages.Count > 2) { int sent = Convert.ToInt32((channelStatus[channel])["sent"]); (channelStatus[channel]).Remove("sent"); (channelStatus[channel]).Add("sent", sent + 1); test(messages != null, "publish complete"); test(messages != null && messages.Count > 2, "publish responce"); channelConnected[channel] = true; } if (messages == null || messages.Count <= 0) { delivery_retries += 1; if (max_retries > delivery_retries) { publishAndSetStatus(channel, message); } } }; // Publish message Dictionary <string, object> args = new Dictionary <string, object>(2); args.Add("channel", channel); args.Add("message", message); args.Add("callback", publishCallback); // publish Response _pubnub.Publish(args); }
static public 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); }
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"; 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 RequestState() { BufferRead = new byte[BUFFER_SIZE]; requestData = new StringBuilder(""); request = null; streamResponse = null; cb = null; }
private void btnTime_Click(object sender, RoutedEventArgs e) { Pubnub.ResponseCallback respCallback = delegate(object response) { List <object> result = (List <object>)response; System.Diagnostics.Debug.WriteLine("Server Time : " + result[0]); }; pubnub.Time(respCallback); }
private void btnPublish_Click(object sender, RoutedEventArgs e) { Pubnub.ResponseCallback respCallback = delegate(object response) { List <object> result = (List <object>)response; if (result != null && result.Count() > 0) { System.Diagnostics.Debug.WriteLine("[" + result[0].ToString() + "," + result[1].ToString() + "," + result[2].ToString() + "]"); } }; // Publish string message Dictionary <string, object> strArgs = new Dictionary <string, object>(); string message = "Hello Windows Phone 7"; strArgs.Add("channel", channel); strArgs.Add("message", message); strArgs.Add("callback", respCallback); pubnub.Publish(strArgs); // Publish message in array format Dictionary <string, object> arrArgs = 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"); arrArgs.Add("channel", channel); arrArgs.Add("message", jarr); arrArgs.Add("callback", respCallback); pubnub.Publish(arrArgs); // Publish message in Dictionary format Dictionary <string, object> objArgs = new Dictionary <string, object>(); JObject obj = new JObject(); obj.Add("Name", "Jhon"); obj.Add("age", "25"); objArgs.Add("channel", channel); objArgs.Add("message", obj); objArgs.Add("callback", respCallback); pubnub.Publish(objArgs); }
private void btnTime_Click(object sender, RoutedEventArgs e) { // Initialize pubnub state Pubnub pubnub = new Pubnub( "demo", // PUBLISH_KEY "demo", // SUBSCRIBE_KEY "demo", // SECRET_KEY "", // CIPHER_KEY (Cipher key is Optional) false // SSL_ON? ); Pubnub.ResponseCallback respCallback = delegate(object response) { List <object> result = (List <object>)response; System.Diagnostics.Debug.WriteLine("Server Time : " + result[0]); }; pubnub.Time(respCallback); }
private void btnHistory_Click(object sender, RoutedEventArgs e) { Pubnub.ResponseCallback respCallback = delegate(object response) { List <object> result = (List <object>)response; if (result != null && result.Count() > 0) { for (int i = 0; i < result.Count(); i++) { System.Diagnostics.Debug.WriteLine(result[i]); } } }; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("channel", channel); args.Add("limit", 3.ToString()); args.Add("callback", respCallback); pubnub.History(args); }
private void btnPublish_Click(object sender, RoutedEventArgs e) { Pubnub.ResponseCallback respCallback = delegate(object response) { List <object> result = (List <object>)response; if (result != null && result.Count() > 0) { System.Diagnostics.Debug.WriteLine("[" + result[0].ToString() + "," + result[1].ToString() + "," + result[2].ToString() + "]"); } }; // Publish string message Dictionary <string, object> strArgs = new Dictionary <string, object>(); string message = "Hello Windows Phone 7"; strArgs.Add("channel", channel); strArgs.Add("message", message); strArgs.Add("callback", respCallback); pubnub.Publish(strArgs); }
public void connectCallback(string channel) { if (!channelConnected[channel]) { Pubnub.ResponseCallback histCallback = delegate(object response) { List <object> result = (List <object>)response; test(result != null && result.Count > 0, "history"); }; Debug.WriteLine("Connected to channel :" + channel); int connections = Convert.ToInt32(status["connections"]); status.Remove("connections"); status.Add("connections", connections + 1); publishAndSetStatus(channel, Message); Dictionary <string, object> argshist = new Dictionary <string, object>(); argshist.Add("channel", channel); argshist.Add("limit", 1.ToString()); argshist.Add("callback", histCallback); _pubnub.History(argshist); } }