static void Main(string[] args) { Process.Start("..\\..\\RecieverPage.html"); System.Threading.Thread.Sleep(2000); PubnubAPI pubnub = new PubnubAPI( "pub-c-d9aadadf-abba-443c-a767-62023d43411a", // PUBLISH_KEY "sub-c-102d0358-073f-11e3-916b-02ee2ddab7fe", // SUBSCRIBE_KEY "sec-c-YmI4NDcxNzQtOWZhYi00MTRmLWI4ODktMDI2ZjViMjQyYzdj", // SECRET_KEY false // SSL_ON? ); string channel = "PublishApp"; // Publish a sample message to Pubnub List <object> publishResult = pubnub.Publish(channel, "Hello Pubnub!"); Console.WriteLine( "Publish Success: " + publishResult[0].ToString() + "\n" + "Publish Info: " + publishResult[1] ); // Show PubNub server time object serverTime = pubnub.Time(); Console.WriteLine("Server Time: " + serverTime.ToString()); // Subscribe for receiving messages (in a background task to avoid blocking) System.Threading.Tasks.Task t = new System.Threading.Tasks.Task( () => pubnub.Subscribe( channel, delegate(object message) { Console.WriteLine("Received Message -> '" + message + "'"); return(true); } ) ); t.Start(); // Read messages from the console and publish them to Pubnub while (true) { Console.Write("Enter a message to be sent to Pubnub: "); string msg = Console.ReadLine(); pubnub.Publish(channel, msg); Console.WriteLine("Message {0} sent.", msg); } }
static void Main(string[] args) { Process.Start("..\\..\\RecieverPage.html"); System.Threading.Thread.Sleep(2000); PubnubAPI pubnub = new PubnubAPI( "pub-c-d9aadadf-abba-443c-a767-62023d43411a", // PUBLISH_KEY "sub-c-102d0358-073f-11e3-916b-02ee2ddab7fe", // SUBSCRIBE_KEY "sec-c-YmI4NDcxNzQtOWZhYi00MTRmLWI4ODktMDI2ZjViMjQyYzdj", // SECRET_KEY false // SSL_ON? ); string channel = "PublishApp"; // Publish a sample message to Pubnub List<object> publishResult = pubnub.Publish(channel, "Hello Pubnub!"); Console.WriteLine( "Publish Success: " + publishResult[0].ToString() + "\n" + "Publish Info: " + publishResult[1] ); // Show PubNub server time object serverTime = pubnub.Time(); Console.WriteLine("Server Time: " + serverTime.ToString()); // Subscribe for receiving messages (in a background task to avoid blocking) System.Threading.Tasks.Task t = new System.Threading.Tasks.Task( () => pubnub.Subscribe( channel, delegate(object message) { Console.WriteLine("Received Message -> '" + message + "'"); return true; } ) ); t.Start(); // Read messages from the console and publish them to Pubnub while (true) { Console.Write("Enter a message to be sent to Pubnub: "); string msg = Console.ReadLine(); pubnub.Publish(channel, msg); Console.WriteLine("Message {0} sent.", msg); } }
static void Main() { // Start the HTML5 Pubnub client //Process.Start("..\\..\\PubNub-HTML5-Client.html"); System.Threading.Thread.Sleep(2000); PubnubAPI pubnub = new PubnubAPI( "pub-c-de6261aa-bb9e-4e17-a46c-ea4cb2b08f96", // PUBLISH_KEY "sub-c-28202fc4-8d72-11e5-a7e4-0619f8945a4f", // SUBSCRIBE_KEY "sec-c-ZDM3ZTEwY2UtMTMyZC00NWZmLTgzNDEtMGY3NjkyNzM4ZmM3", // SECRET_KEY true // SSL_ON? ); string channel = "demo-channel"; // Publish a sample message to Pubnub List<object> publishResult = pubnub.Publish(channel, "Hello Pubnub!"); Console.WriteLine( "Publish Success: " + publishResult[0].ToString() + "\n" + "Publish Info: " + publishResult[1] ); // Subscribe for receiving messages (in a background task to avoid blocking) System.Threading.Tasks.Task t = new Task( () => pubnub.Subscribe( channel, delegate(object message) { Console.WriteLine("Received Message -> '" + message + "'"); Console.Write("Enter a message to be sent to Pubnub: "); return true; } ) ); t.Start(); var ip = GetIp(); // Read messages from the console and publish them to Pubnub Console.Write("Enter a message to be sent to Pubnub: "); while (true) { var msg = Console.ReadLine(); var result = ip + ": " + msg; pubnub.Publish(channel, result); Console.WriteLine("Message sent."); } }