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); Debug.WriteLine(""); Debug.WriteLine("History messages - > "); foreach (object history_message in history) { 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? ); // 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); } }
static public 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); } }
protected void btnHistory_Click(object sender, EventArgs e) { // 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); } }
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); } }
public static void run(object _channel) { //Subscribe messages pubnub.Procedure Receiver = delegate(object message) { int sent = Convert.ToInt32(status["sent"]); int received = Convert.ToInt32(status["received"]); test(received <= sent, "many sends"); status.Remove("received"); status.Add("received", received + 1); Dictionary <String, Object> args = new Dictionary <String, Object>(1); args.Add("channel", _channel); _pubnub.Unsubscribe(args); Dictionary <String, string> argsHistory = new Dictionary <String, string>(2); argsHistory.Add("channel", _channel.ToString()); argsHistory.Add("limit", "2"); List <object> response = _pubnub.History(argsHistory); test(response != null && response.Count > 0, "history"); Debug.WriteLine("received count " + Convert.ToInt32(status["received"])); if (Convert.ToInt32(status["received"]) == many_channels.Count) { runthroughs += 1; if (runthroughs < planned_tests) { UnitTestAll(_pubnub); } } return(true); }; pubnub.Procedure ConnectCallback = delegate(object message) { Debug.WriteLine(message); int connections = Convert.ToInt32(status["connections"]); status.Remove("connections"); status.Add("connections", connections + 1); publishAndSetStatus(_channel.ToString(), 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> argsSub = new Dictionary <String, Object>(6); argsSub.Add("channel", _channel.ToString()); argsSub.Add("callback", Receiver); // callback to get response argsSub.Add("connect_cb", ConnectCallback); // callback to get connect event argsSub.Add("disconnect_cb", DisconnectCallback); // callback to get disconnect event argsSub.Add("reconnect_cb", ReconnectCallback); // callback to get reconnect event argsSub.Add("error_cb", ErrorCallback); // callback to get error event // Listen for Messages (Subscribe) _pubnub.Subscribe(argsSub); }