예제 #1
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            isEncryptObjectPublished = false;
            Pubnub pubnub  = new Pubnub("demo", "demo", "", "enigma", false);
            string channel = "my/channel";
            object message = new SecretCustomClass();

            messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);

            EnqueueCallback(() => pubnub.publish <string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback));
            EnqueueConditional(() => isEncryptObjectPubCheck);

            EnqueueCallback(() =>
            {
                if (!isEncryptObjectPublished)
                {
                    Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish Failed");
                }
                else
                {
                    EnqueueCallback(() => pubnub.detailedHistory <string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback));
                    EnqueueConditional(() => isEncryptObjectDHCheck);
                    EnqueueCallback(() => Assert.IsTrue(isEncryptObjectDH, "Unable to match the successful encrypt object Publish"));
                }
            });

            EnqueueTestComplete();
        }
예제 #2
0
        internal static void PublishDemo()
        {
            Pubnub pubnub = new Pubnub(
                        "demo",
                        "demo",
                        "",
                        "",
                        false);

            string channel = "my_channel";

            Console.WriteLine("Publish_Example");

            bool exitFlag = false;
            while (!exitFlag)
            {
                Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
                string userinput = Console.ReadLine();
                if (userinput.ToLower() == "quit")
                {
                    exitFlag = true;
                }
                else
                {
                    pubnub.publish(channel, userinput, DisplayReturnMessage);
                }
            }
        }
        public static void Main()
        {
            Pubnub pubnub = new Pubnub(
            "demo",
            "demo",
            "",
            false
            );
            string channel = "my/channel";
            string message = "Pubnub API Usage Example";

            pubnub.PropertyChanged += new PropertyChangedEventHandler(Pubnub_PropertyChanged);

            Console.WriteLine("UUID -> " + pubnub.generateGUID());

            pubnub.publish(channel, message);

            pubnub.history(channel, 10);

            pubnub.time();

            pubnub.subscribe(channel);

            Console.ReadKey();
        }
예제 #4
0
        public void ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
        {
            isSecretEncryptPublished = false;
            Pubnub pubnub  = new Pubnub("demo", "demo", "key", "enigma", false);
            string channel = "my/channel";
            string message = messageForSecretEncryptPublish;

            EnqueueCallback(() => pubnub.publish <string>(channel, message, ReturnSuccessSecretEncryptPublishCodeCallback));
            EnqueueConditional(() => isSecretEncryptPubCheck);

            EnqueueCallback(() =>
            {
                if (!isSecretEncryptPublished)
                {
                    Assert.IsTrue(isSecretEncryptPublished, "Secret Encrypt Publish Failed");
                }
                else
                {
                    EnqueueCallback(() => pubnub.detailedHistory <string>(channel, -1, secretEncryptPublishTimetoken, -1, false, CaptureSecretEncryptDetailedHistoryCallback));
                    EnqueueConditional(() => isSecretEncryptDHCheck);
                    EnqueueCallback(() => Assert.IsTrue(isSecretEncryptDH, "Unable to decrypt the successful Secret key Publish"));
                }
            });

            EnqueueTestComplete();
        }
        public void ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
        {
            isUnencryptPublished = false;
            Pubnub pubnub = new Pubnub("demo","demo","","",false);
            string channel = "my/channel";
            string message = messageForUnencryptPublish;

            EnqueueCallback(() => pubnub.publish<string>(channel, message, ReturnSuccessUnencryptPublishCodeCallback));
            EnqueueConditional(() => isCheck);

            EnqueueCallback(() => 
            {
                if (!isUnencryptPublished)
                {
                    Assert.IsTrue(isUnencryptPublished, "Unencrypt Publish Failed");
                }
                else
                {
                    EnqueueCallback(() => pubnub.detailedHistory<string>(channel, -1, unEncryptPublishTimetoken, -1, false, CaptureUnencryptDetailedHistoryCallback));
                    EnqueueConditional(() => isUnencryptCheck);
                    EnqueueCallback(() => Assert.IsTrue(isUnencryptDH, "Unable to match the successful unencrypt Publish"));
                }
            });

            EnqueueTestComplete();
        }
예제 #6
0
        public static void Publish_Example()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
                );
            string channel = "hello_world";
            string message = "Pubnub API Usage Example";

            deliveryStatus = false;

            pubnub.publish(channel, message, DisplayReturnMessage);
            //wait till the response is received from the server
            while (!deliveryStatus)
            {
                ;
            }
            IList <object> fields  = objResponse as IList <object>;
            string         strSent = fields[1].ToString();
            string         strOne  = fields[0].ToString();

            Console.WriteLine("Sent: " + strSent);
            Console.WriteLine("One: " + strOne);
        }
예제 #7
0
        public void ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
        {
            isUnencryptPublished = false;
            Pubnub pubnub  = new Pubnub("demo", "demo", "", "", false);
            string channel = "my/channel";
            string message = messageForUnencryptPublish;

            EnqueueCallback(() => pubnub.publish <string>(channel, message, ReturnSuccessUnencryptPublishCodeCallback));
            EnqueueConditional(() => isCheck);

            EnqueueCallback(() =>
            {
                if (!isUnencryptPublished)
                {
                    Assert.IsTrue(isUnencryptPublished, "Unencrypt Publish Failed");
                }
                else
                {
                    EnqueueCallback(() => pubnub.detailedHistory <string>(channel, -1, unEncryptPublishTimetoken, -1, false, CaptureUnencryptDetailedHistoryCallback));
                    EnqueueConditional(() => isUnencryptCheck);
                    EnqueueCallback(() => Assert.IsTrue(isUnencryptDH, "Unable to match the successful unencrypt Publish"));
                }
            });

            EnqueueTestComplete();
        }
예제 #8
0
        public static void DetailedHistory_Decrypted_Example()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "enigma",
                    false);
            string channel = "testchannel";
            //pubnub.CIPHER_KEY = "enigma";
            string msg = "Test Message";

            deliveryStatus = false;
            pubnub.publish(channel, msg, DisplayReturnMessage);
            while (!deliveryStatus) ;

            deliveryStatus = false;
            pubnub.detailedHistory(channel, 1, DisplayReturnMessage);
            while (!deliveryStatus) ;
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");

            if (objResponse.Equals(null))
            {
              Console.WriteLine("Null response");
            }
            else
            {
                IList<object> fields = objResponse as IList<object>;
                Console.WriteLine("fields[0]: " + fields[0]);
                Console.WriteLine("fields[1]: " + fields[1]);
                //Assert.AreEqual(fields[0], msg);
            }
        }
예제 #9
0
        public void NullMessage()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );
            string channel = "hello_world";
            string message = null;

            Common cm = new Common();
            cm.deliveryStatus = false;
            cm.objResponse = null;

            pubnub.publish(channel, message, cm.DisplayReturnMessage);
            //wait till the response is received from the server
            while (!cm.deliveryStatus) ;
            IList<object> fields = cm.objResponse as IList<object>;
            string strSent = fields[1].ToString();
            string strOne = fields[0].ToString();
            Assert.True(("Sent").Equals(strSent));
            Assert.True(("1").Equals(strOne));
        }
예제 #10
0
        public void ThenItShouldReturnSuccessCodeAndInfo()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );
            string channel = "hello_world";
            string message = "Pubnub API Usage Example";

            Common cm = new Common();
			PubnubUnitTest unitTest = new PubnubUnitTest();
			unitTest.TestClassName = "WhenAMessageIsPublished";
			unitTest.TestCaseName = "ThenItShouldReturnSuccessCodeAndInfo";
			
			pubnub.PubnubUnitTest = unitTest;
            cm.deliveryStatus = false;
            cm.objResponse = null;

            pubnub.publish(channel, message, cm.DisplayReturnMessage);
            //wait till the response is received from the server
            while (!cm.deliveryStatus) ;
            IList<object> fields = cm.objResponse as IList<object>;
            string strSent = fields[1].ToString();
            string strOne = fields[0].ToString();
            Assert.True(("Sent").Equals(strSent));
            Assert.True(("1").Equals(strOne));
        }
예제 #11
0
        public void ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
        {
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    isUnencryptPublished = false;
                    Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
                    string channel = "my/channel";
                    string message = messageForUnencryptPublish;

                    pubnub.publish<string>(channel, message, ReturnSuccessUnencryptPublishCodeCallback);
                    manualEvent1.WaitOne(310 * 1000);

                    if (!isUnencryptPublished)
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(isUnencryptPublished, "Unencrypt Publish Failed");
                           TestComplete();
                       });
                    }
                    else
                    {
                        pubnub.detailedHistory<string>(channel, -1, unEncryptPublishTimetoken, -1, false, CaptureUnencryptDetailedHistoryCallback);
                        mreUnencryptDH.WaitOne(310 * 1000);
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(isUnencryptDH, "Unable to match the successful unencrypt Publish");
                           TestComplete();
                       });
                    }
                });
        }
예제 #12
0
        internal static void PublishDemo()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false);

            string channel = "my_channel";

            Console.WriteLine("Publish_Example");

            bool exitFlag = false;

            while (!exitFlag)
            {
                Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
                string userinput = Console.ReadLine();
                if (userinput.ToLower() == "quit")
                {
                    exitFlag = true;
                }
                else
                {
                    pubnub.publish(channel, userinput, DisplayReturnMessage);
                }
            }
        }
    public void ItShouldReturnDetailedHistory()
    {
     Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
     );
     string channel = "hello_world";

     Common cm = new Common();
     cm.deliveryStatus = false;
     cm.objResponse = null;

     //publish a test message. 
     pubnub.publish(channel, "Test message", cm.DisplayReturnMessage);
             
     while (!cm.deliveryStatus)
       ; 

     cm.deliveryStatus = false;
     cm.objResponse = null;
     pubnub.detailedHistory(channel, 1, cm.DisplayReturnMessage);
     while (!cm.deliveryStatus)
       ;

     string strResponse = "";
     if (cm.objResponse.Equals(null))
       {
        Assert.Fail("Null response");
       } else
        {
          IList<object> fields = cm.objResponse as IList<object>;
          foreach (object item in fields)
            {
             strResponse = item.ToString();
             Console.WriteLine(strResponse);

             Assert.IsNotNull(strResponse);
            }             
            if (fields [0] != null)
             {
               var myObjectArray = (from item in fields select item as object).ToArray();
               IList<object> enumerable = myObjectArray [0] as IList<object>;
               if ((enumerable != null) && (enumerable.Count > 0))
                {
                  foreach (object element in enumerable)
                    {
                     Console.WriteLine("Resp:" + element.ToString());
                    }
                }
                else
                {
                    Assert.Fail("No response");
                }
             }
        }
       }
예제 #14
0
        public void ThenPublishKeyShouldNotBeEmpty()
        {
            Pubnub pubnub = new Pubnub("", "demo", "", "", false);

            string channel = "my/channel";
            string message = "Pubnub API Usage Example";

            pubnub.publish <string>(channel, message, null);
        }
 public void IfSSLNotProvidedThenDefaultShouldBeFalse()
 {
     Pubnub pubnub = new Pubnub(
         "demo",
         "demo",
         ""
     );
     string channel = "hello_world";
     string message = "Pubnub API Usage Example";
     Common cm = new Common();
     Assert.AreEqual(true, pubnub.publish(channel, message, cm.DisplayReturnMessage));
 }
예제 #16
0
        public void IfSSLNotProvidedThenDefaultShouldBeFalse()
        {
            isPublished3 = false;
            Pubnub pubnub  = new Pubnub("demo", "demo", "");
            string channel = "my/channel";
            string message = "Pubnub API Usage Example";

            EnqueueCallback(() => pubnub.publish <string>(channel, message, ReturnNoSSLDefaultFalseCallback));
            EnqueueConditional(() => isCkeck3);
            EnqueueCallback(() => Assert.IsTrue(isPublished3, "Publish Failed with no SSL"));

            EnqueueTestComplete();
        }
예제 #17
0
        public void ThenOptionalSecretKeyShouldBeProvidedInConstructor()
        {
            isPublished2 = false;
            Pubnub pubnub  = new Pubnub("demo", "demo", "key");
            string channel = "my/channel";
            string message = "Pubnub API Usage Example";

            EnqueueCallback(() => pubnub.publish <string>(channel, message, ReturnSecretKeyPublishCallback));
            EnqueueConditional(() => isCkeck2);
            EnqueueCallback(() => Assert.IsTrue(isPublished2, "Publish Failed with secret key"));

            EnqueueTestComplete();
        }
 public void NullShouldBeTreatedAsEmpty()
 {
     Pubnub pubnub = new Pubnub(
         null,
         "demo",
         null,
         null,
         false
     );
     string channel = "mychannel";
     string message = "Pubnub API Usage Example";
     Common cm = new Common();
     Assert.AreEqual(false, pubnub.publish(channel, message, cm.DisplayReturnMessage));
 }
예제 #19
0
        public void ThenSubscribeShouldReturnReceivedMessage()
        {
            receivedMessage = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            string channel = "test";

            EnqueueCallback(() => pubnub.subscribe <string>(channel, ReceivedMessageCallback));
            EnqueueCallback(() => pubnub.publish <string>(channel, "Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage", dummyPublishCallback));
            EnqueueConditional(() => isPublished);
            EnqueueConditional(() => isReceived);
            EnqueueCallback(() => Assert.IsTrue(receivedMessage, "WhenSubscribedToAChannel --> ThenItShouldReturnReceivedMessage Failed"));

            EnqueueTestComplete();
        }
        public void ThenSubscribeShouldReturnReceivedMessage()
        {
            receivedMessage = false;
            Pubnub pubnub = new Pubnub("demo","demo","","",false);

            string channel = "test";

            EnqueueCallback(() => pubnub.subscribe<string>(channel, ReceivedMessageCallback));
            EnqueueCallback(() => pubnub.publish<string>(channel, "Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage", dummyPublishCallback));
            EnqueueConditional(() => isPublished);
            EnqueueConditional(() => isReceived);
            EnqueueCallback(() => Assert.IsTrue(receivedMessage, "WhenSubscribedToAChannel --> ThenItShouldReturnReceivedMessage Failed"));

            EnqueueTestComplete();
        }
예제 #21
0
		public void ThenItShouldReturnReceivedMessage () 
		{
			
			Pubnub pubnub = new Pubnub (
				"demo",
				"demo",
				"",
				"",
				false);
			string channel = "hello_world";
			
			Common cm = new Common();
			cm.deliveryStatus = false;
			cm.objResponse = null;
			
			PubnubUnitTest unitTest = new PubnubUnitTest();
			unitTest.TestClassName = "WhenSubscribedToAChannel";
			unitTest.TestCaseName = "ThenSubscribeShouldReturnReceivedMessage";
			
			pubnub.PubnubUnitTest = unitTest;
			
			pubnub.subscribe (channel, cm.DisplayReturnMessage); 
			Thread.Sleep(3000);
			string msg = "Test Message";
			
			pubnub.publish (channel, msg, cm.DisplayReturnMessageDummy);
			//cm.deliveryStatus = false;
			while (!cm.deliveryStatus);
			if (cm.objResponse != null) {
				IList<object> fields = cm.objResponse as IList<object>;
				
				if (fields [0] != null)
				{
					var myObjectArray = (from item in fields select item as object).ToArray ();
					Console.WriteLine ("Resp:" + myObjectArray[0].ToString ());
					Assert.AreEqual(msg, myObjectArray[0].ToString());
				}
				else
				{
					Assert.Fail("No response");
				}
			}
			else
			{
				Assert.Fail("No response");
			}
		}
예제 #22
0
        private void Publish_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Running publish()");

            PublishMessageDialog view = new PublishMessageDialog();

            view.Show();

            view.Closed += (obj, args) =>
            {
                if (view.DialogResult == true)
                {
                    string publishMsg = view.Message.Text;
                    pubnub.publish <string>(channel, publishMsg, DisplayReturnMessage);
                }
            };
        }
예제 #23
0
        public static void TestUnencryptedHistory()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false);
            string channel = "testchannel";

            //pubnub.CIPHER_KEY = "";

            deliveryStatus = false;
            string message = "Pubnub API Usage Example - Publish";


            pubnub.publish(channel, message, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }
            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
                if (e.PropertyName == "History")
                {
                    Console.WriteLine("\n*********** History Messages *********** ");
                    deliveryStatus = true;
                }
            };
            pubnub.history(channel, 1);

            deliveryStatus = false;

            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("\n*********** Publish *********** ");
            if (pubnub.History[0].Equals(null))
            {
                Console.WriteLine("Null response");
            }
            else
            {
                Console.WriteLine(pubnub.History[0].ToString());
            }
        }
        public void ThenItShouldReturnHistoryMessages ()
        {
            Pubnub pubnub = new Pubnub (
                "demo",
                "demo",
                "",
                "",
                false
            );
            string channel = "hello_world";
            bool responseStatus = false;
            //publish a test message.
            Common cm = new Common();
            cm.deliveryStatus = false;
            cm.objResponse = null;
            pubnub.publish (channel, "Test message", cm.DisplayReturnMessage);

            List<object> lstHistory = null;

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
                if (e.PropertyName == "History")
                {
                    lstHistory = ((Pubnub)sender).History;
           
                    responseStatus = true;
                }
            };

            pubnub.history(channel, 1);

            /*while (!responseStatus) ;

            string strResponse = "";
            if (lstHistory.Equals (null)) {
                Assert.Fail("Null response");
            }
            else
            {
                foreach(object lst in lstHistory)
                {
                    strResponse = lst.ToString();
                    Console.WriteLine("resp:" + strResponse);
                    Assert.IsNotEmpty(strResponse);
                }
            }*/
        }
예제 #25
0
        public static void DetailedHistory_Example()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false);
            string channel = "testchannel";
            //pubnub.CIPHER_KEY = "";
            string msg = "Test Message";

            deliveryStatus = false;
            pubnub.publish(channel, msg, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }

            deliveryStatus = false;
            pubnub.detailedHistory(channel, 10, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");

            if (objResponse.Equals(null))
            {
                Console.WriteLine("Null response");
            }
            else
            {
                IList <object> fields = objResponse as IList <object>;

                foreach (object item in fields)
                {
                    string strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0}", strResponse));
                    Console.WriteLine(strResponse);
                }
            }
        }
예제 #26
0
        public static void Subscribe_Example()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false);
            string channel = "hello_world";

            deliveryStatus = false;

            pubnub.subscribe(channel, DisplayReturnMessage);

            pubnub.publish(channel, "Test Message", DisplayReturnMessage);

            bool bStop = false;

            while (!bStop)
            {
                if (objResponse != null)
                {
                    IList <object> fields = objResponse as IList <object>;

                    if (fields [0] != null)
                    {
                        var         myObjectArray = (from item in fields select item as object).ToArray();
                        IEnumerable enumerable    = myObjectArray [0] as IEnumerable;
                        if (enumerable != null)
                        {
                            foreach (object element in enumerable)
                            {
                                Console.WriteLine("Resp:" + element.ToString());
                                bStop = true;
                            }
                        }
                    }
                }
            }
        }
        public static void TestUnencryptedHistory()
        {
             Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            string channel = "my_channel";
            Common cm = new Common();
            cm.deliveryStatus = false;
            cm.objResponse = null;

            string message = "Pubnub API Usage Example - Publish";
            //pubnub.CIPHER_KEY = "enigma";

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "History")
                {
                    Console.WriteLine("\n*********** History Messages *********** ");
                    cm.deliveryStatus = true;
                }
            };
            cm.deliveryStatus = false;
            pubnub.publish(channel, message, cm.DisplayReturnMessage);
            while (!cm.deliveryStatus) ;

            cm.deliveryStatus = false;
            pubnub.history(channel, 1);
            while (!cm.deliveryStatus) ;
            if (pubnub.History[0].Equals (null)) {
                Assert.Fail("Null response");
            }
            else
            {
                Assert.True(message.Equals(pubnub.History[0].ToString()));
            }
        }
예제 #28
0
        public static void DetailedHistory_Decrypted_Example()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "enigma",
                false);
            string channel = "testchannel";
            //pubnub.CIPHER_KEY = "enigma";
            string msg = "Test Message";

            deliveryStatus = false;
            pubnub.publish(channel, msg, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }

            deliveryStatus = false;
            pubnub.detailedHistory(channel, 1, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");

            if (objResponse.Equals(null))
            {
                Console.WriteLine("Null response");
            }
            else
            {
                IList <object> fields = objResponse as IList <object>;
                Console.WriteLine("fields[0]: " + fields[0]);
                Console.WriteLine("fields[1]: " + fields[1]);
                //Assert.AreEqual(fields[0], msg);
            }
        }
예제 #29
0
        static void Publish_Example()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    false);
            string channel = "hello_world";
            string message = "Pubnub API Usage Example - Publish";

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Publish")
                {
                    Console.WriteLine("\n*********** Publish Messages *********** ");
                    Console.WriteLine(
                        "Publish Success: " + ((Pubnub)sender).Publish[0].ToString() +
                        "\nPublish Info: " + ((Pubnub)sender).Publish[1].ToString()
                        );
                }
            };
            pubnub.publish(channel, message);
        }
예제 #30
0
        static void Publish_Example()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                false);
            string channel = "hello_world";
            string message = "Pubnub API Usage Example - Publish";

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Publish")
                {
                    Console.WriteLine("\n*********** Publish Messages *********** ");
                    Console.WriteLine(
                        "Publish Success: " + ((Pubnub)sender).Publish[0].ToString() +
                        "\nPublish Info: " + ((Pubnub)sender).Publish[1].ToString()
                        );
                }
            };
            pubnub.publish(channel, message);
        }
예제 #31
0
        public void Publish()
        {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            alert.SetTitle("Publish");
            alert.SetMessage("Enter message to publish");

            // Set an EditText view to get user input
            EditText input = new EditText(this);

            alert.SetView(input);

            alert.SetPositiveButton("OK", (sender, e) =>
            {
                Display("Running Publish");
                pubnub.publish <string> (channel, input.Text, DisplayReturnMessage);
            });

            alert.SetNegativeButton("Cancel", (sender, e) =>
            {
            });
            alert.Show();
            //this.RunOnUiThread(() => alert.Show());
        }
예제 #32
0
        public void ThenSecretKeyShouldBeProvidedOptionally()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo"
            );
            string channel = "mychannel";
            string message = "Pubnub API Usage Example";
            Common cm = new Common();
            Assert.True((true).Equals(pubnub.publish(channel, message, cm.DisplayReturnMessage)));
            pubnub = new Pubnub(
                "demo",
                "demo",
                "key"
            );
			Assert.True((true).Equals(pubnub.publish(channel, message, cm.DisplayReturnMessage)));
        }
예제 #33
0
        static public void Main()
        {
            Console.WriteLine("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
            Console.WriteLine("      DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
            Console.WriteLine("      RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
            Console.WriteLine();
            Console.WriteLine("      IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
            Console.WriteLine("      NETWORK ERROR MESSAGE WILL BE SENT");
            Console.WriteLine();

            Console.WriteLine("ENTER Channel Name");
            channel = Console.ReadLine();

            Console.WriteLine(string.Format("Channel = {0}", channel));
            Console.WriteLine();

            Console.WriteLine("ENTER 1 FOR Subscribe");
            Console.WriteLine("ENTER 2 FOR Publish");
            Console.WriteLine("ENTER 3 FOR Presence");
            Console.WriteLine("ENTER 4 FOR Detailed History");
            Console.WriteLine("ENTER 5 FOR Here_Now");
            Console.WriteLine("ENTER 6 FOR Unsubscribe");
            Console.WriteLine("ENTER 7 FOR Presence-Unsubscribe");
            Console.WriteLine("ENTER 8 FOR Time");
            Console.WriteLine("ENTER 0 FOR EXIT OR QUIT");

            bool exitFlag = false;

            Console.WriteLine("");
            while (!exitFlag)
            {
                string userinput = Console.ReadLine();
                switch (userinput)
                {
                case "0":
                    exitFlag = true;
                    break;

                case "1":
                    Console.WriteLine("Running subscribe()");
                    pubnub.subscribe <string>(channel, DisplayReturnMessage);
                    //pubnub.subscribe<object>(channel, DisplayReturnMessage);
                    //pubnub.subscribe(channel, DisplayReturnMessage);
                    break;

                case "2":
                    Console.WriteLine("Running publish()");
                    Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
                    string publishMsg = Console.ReadLine();
                    pubnub.publish <string>(channel, publishMsg, DisplayReturnMessage);
                    break;

                case "3":
                    Console.WriteLine("Running presence()");
                    pubnub.presence <string>(channel, DisplayReturnMessage);
                    //pubnub.presence<object>(channel, DisplayReturnMessage);
                    break;

                case "4":
                    Console.WriteLine("Running detailed history()");
                    pubnub.detailedHistory <string>(channel, 100, DisplayReturnMessage);
                    //pubnub.detailedHistory<object>(channel, 100, DisplayReturnMessage);
                    break;

                case "5":
                    Console.WriteLine("Running Here_Now()");
                    pubnub.here_now <string>(channel, DisplayReturnMessage);
                    //pubnub.here_now<object>(channel, DisplayReturnMessage);
                    break;

                case "6":
                    Console.WriteLine("Running unsubscribe()");
                    pubnub.unsubscribe <string>(channel, DisplayReturnMessage);
                    //pubnub.unsubscribe<object>(channel, DisplayReturnMessage);
                    break;

                case "7":
                    Console.WriteLine("Running presence-unsubscribe()");
                    pubnub.presence_unsubscribe <string>(channel, DisplayReturnMessage);
                    break;

                case "8":
                    Console.WriteLine("Running time()");
                    pubnub.time <string>(DisplayReturnMessage);
                    break;

                default:
                    Console.WriteLine("INVALID CHOICE.");
                    break;
                }
            }

            Console.WriteLine("\nPress any key to confirm exit.\n\n");
            Console.ReadLine();
        }
예제 #34
0
        static public void Main()
        {
            Console.WriteLine("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
            Console.WriteLine("      DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
            Console.WriteLine("      RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
            Console.WriteLine();
            Console.WriteLine("      IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
            Console.WriteLine("      NETWORK ERROR MESSAGE WILL BE SENT");
            Console.WriteLine();

            Console.WriteLine("ENTER Channel Name");
            channel = Console.ReadLine();

            Console.WriteLine(string.Format("Channel = {0}",channel));
            Console.WriteLine();

            Console.WriteLine("Enable SSL? ENTER Y for Yes, else N");
            string enableSSL = Console.ReadLine();
            if (enableSSL.Trim().ToLower() == "y")
            {
                Console.WriteLine("SSL Enabled");
            }
            else
            {
                Console.WriteLine("SSL NOT Enabled");
            }
            Console.WriteLine();

            Console.WriteLine("ENTER cipher key for encryption feature.");
            Console.WriteLine("If you don't want to avail at this time, press ENTER.");
            string cipheryKey = Console.ReadLine();
            if (cipheryKey.Trim().Length > 0)
            {
                Console.WriteLine("Cipher key provided.");
            }
            else
            {
                Console.WriteLine("No Cipher key provided");
            }
            Console.WriteLine();

            pubnub = new Pubnub("demo", "demo", "", cipheryKey,
                (enableSSL.Trim().ToLower() == "y") ? true : false);

            Console.WriteLine("ENTER 1 FOR Subscribe (not implementing connectCallback)");
            Console.WriteLine("ENTER 2 FOR Subscribe (implementing connectCallback)");
            Console.WriteLine("ENTER 3 FOR Publish");
            Console.WriteLine("ENTER 4 FOR Presence");
            Console.WriteLine("ENTER 5 FOR Detailed History");
            Console.WriteLine("ENTER 6 FOR Here_Now");
            Console.WriteLine("ENTER 7 FOR Unsubscribe");
            Console.WriteLine("ENTER 8 FOR Presence-Unsubscribe");
            Console.WriteLine("ENTER 9 FOR Time");
            Console.WriteLine("ENTER 0 FOR EXIT OR QUIT");

            bool exitFlag = false;

            Console.WriteLine("");
            while (!exitFlag)
            {
                string userinput = Console.ReadLine();
                switch (userinput)
                {
                    case "0":
                        exitFlag = true;
                        break;
                    case "1":
                        Console.WriteLine("Running subscribe() (not implementing connectCallback)");
                        pubnub.subscribe<string>(channel, DisplayReturnMessage);
                        //System.Threading.Tasks.Task subtask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.subscribe<string>(channel, DisplayReturnMessage));
                        //pubnub.subscribe<object>(channel, DisplayReturnMessage);
                        //pubnub.subscribe(channel, DisplayReturnMessage);
                        break;
                    case "2":
                        Console.WriteLine("Running subscribe() (implementing connectCallback)");
                        pubnub.subscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage);
                        //System.Threading.Tasks.Task subtask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.subscribe<string>(channel, DisplayReturnMessage));
                        //pubnub.subscribe<object>(channel, DisplayReturnMessage);
                        //pubnub.subscribe(channel, DisplayReturnMessage);
                        break;
                    case "3":
                        Console.WriteLine("Running publish()");
                        Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
                        string publishMsg = Console.ReadLine();
                        double doubleData;
                        int intData;
                        if (int.TryParse(publishMsg, out intData))
                        {
                            pubnub.publish<string>(channel, intData, DisplayReturnMessage);
                        }
                        else if (double.TryParse(publishMsg, out doubleData))
                        {
                            pubnub.publish<string>(channel, doubleData, DisplayReturnMessage);
                        }
                        else
                        {
                            //check whether any numeric is sent in double quotes
                            if (publishMsg.IndexOf("\"") == 0 && publishMsg.LastIndexOf("\"") == publishMsg.Length - 1)
                            {
                                string strMsg = publishMsg.Substring(1, publishMsg.Length - 2);
                                if (int.TryParse(strMsg, out intData))
                                {
                                    pubnub.publish<string>(channel, strMsg, DisplayReturnMessage);
                                }
                                else if (double.TryParse(strMsg, out doubleData))
                                {
                                    pubnub.publish<string>(channel, strMsg, DisplayReturnMessage);
                                }
                                else
                                {
                                    pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage);
                                }
                            }
                            else
                            {
                                pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage);
                            }
                        }
                        break;
                    case "4":
                        Console.WriteLine("Running presence()");
                        pubnub.presence<string>(channel, DisplayReturnMessage);
                        //System.Threading.Tasks.Task pretask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.presence<string>(channel, DisplayReturnMessage));
                        //pubnub.presence<object>(channel, DisplayReturnMessage);
                        break;
                    case "5":
                        Console.WriteLine("Running detailed history()");
                        pubnub.detailedHistory<string>(channel, 100, DisplayReturnMessage);
                        //pubnub.detailedHistory<object>(channel, 100, DisplayReturnMessage);
                        break;
                    case "6":
                        Console.WriteLine("Running Here_Now()");
                        pubnub.here_now<string>(channel, DisplayReturnMessage);
                        //pubnub.here_now<object>(channel, DisplayReturnMessage);
                        break;
                    case "7":
                        Console.WriteLine("Running unsubscribe()");
                        pubnub.unsubscribe<string>(channel, DisplayReturnMessage);
                        //pubnub.unsubscribe<object>(channel, DisplayReturnMessage);
                        break;
                    case "8":
                        Console.WriteLine("Running presence-unsubscribe()");
                        pubnub.presence_unsubscribe<string>(channel, DisplayReturnMessage);
                        break;
                    case "9":
                        Console.WriteLine("Running time()");
                        pubnub.time<string>(DisplayReturnMessage);
                        break;
                    default:
                        Console.WriteLine("INVALID CHOICE.");
                        break;
                }
            }

            Console.WriteLine("\nPress any key to confirm exit.\n\n");
            Console.ReadLine();

        }
예제 #35
0
        static public void Main()
        {
            Console.WriteLine("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
            Console.WriteLine("      DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
            Console.WriteLine("      RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
            Console.WriteLine();
            Console.WriteLine("      IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
            Console.WriteLine("      NETWORK ERROR MESSAGE WILL BE SENT");
            Console.WriteLine();

            Console.WriteLine("ENTER Channel Name");
            channel = Console.ReadLine();

            Console.WriteLine(string.Format("Channel = {0}", channel));
            Console.WriteLine();

            Console.WriteLine("Enable SSL? ENTER Y for Yes, else N");
            string enableSSL = Console.ReadLine();

            if (enableSSL.Trim().ToLower() == "y")
            {
                Console.WriteLine("SSL Enabled");
            }
            else
            {
                Console.WriteLine("SSL NOT Enabled");
            }
            Console.WriteLine();

            Console.WriteLine("ENTER cipher key for encryption feature.");
            Console.WriteLine("If you don't want to avail at this time, press ENTER.");
            string cipheryKey = Console.ReadLine();

            if (cipheryKey.Trim().Length > 0)
            {
                Console.WriteLine("Cipher key provided.");
            }
            else
            {
                Console.WriteLine("No Cipher key provided");
            }
            Console.WriteLine();

            pubnub = new Pubnub("demo", "demo", "", cipheryKey,
                                (enableSSL.Trim().ToLower() == "y") ? true : false);

            Console.WriteLine("ENTER 1 FOR Subscribe");
            Console.WriteLine("ENTER 2 FOR Publish");
            Console.WriteLine("ENTER 3 FOR Presence");
            Console.WriteLine("ENTER 4 FOR Detailed History");
            Console.WriteLine("ENTER 5 FOR Here_Now");
            Console.WriteLine("ENTER 6 FOR Unsubscribe");
            Console.WriteLine("ENTER 7 FOR Presence-Unsubscribe");
            Console.WriteLine("ENTER 8 FOR Time");
            Console.WriteLine("ENTER 0 FOR EXIT OR QUIT");

            bool exitFlag = false;

            Console.WriteLine("");
            while (!exitFlag)
            {
                string userinput = Console.ReadLine();
                switch (userinput)
                {
                case "0":
                    exitFlag = true;
                    break;

                case "1":
                    Console.WriteLine("Running subscribe()");
                    pubnub.subscribe <string>(channel, DisplayReturnMessage);
                    //System.Threading.Tasks.Task subtask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.subscribe<string>(channel, DisplayReturnMessage));
                    //pubnub.subscribe<object>(channel, DisplayReturnMessage);
                    //pubnub.subscribe(channel, DisplayReturnMessage);
                    break;

                case "2":
                    Console.WriteLine("Running publish()");
                    Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
                    string publishMsg = Console.ReadLine();
                    pubnub.publish <string>(channel, publishMsg, DisplayReturnMessage);
                    break;

                case "3":
                    Console.WriteLine("Running presence()");
                    pubnub.presence <string>(channel, DisplayReturnMessage);
                    //System.Threading.Tasks.Task pretask = System.Threading.Tasks.Task.Factory.StartNew(() => pubnub.presence<string>(channel, DisplayReturnMessage));
                    //pubnub.presence<object>(channel, DisplayReturnMessage);
                    break;

                case "4":
                    Console.WriteLine("Running detailed history()");
                    pubnub.detailedHistory <string>(channel, 100, DisplayReturnMessage);
                    //pubnub.detailedHistory<object>(channel, 100, DisplayReturnMessage);
                    break;

                case "5":
                    Console.WriteLine("Running Here_Now()");
                    pubnub.here_now <string>(channel, DisplayReturnMessage);
                    //pubnub.here_now<object>(channel, DisplayReturnMessage);
                    break;

                case "6":
                    Console.WriteLine("Running unsubscribe()");
                    pubnub.unsubscribe <string>(channel, DisplayReturnMessage);
                    //pubnub.unsubscribe<object>(channel, DisplayReturnMessage);
                    break;

                case "7":
                    Console.WriteLine("Running presence-unsubscribe()");
                    pubnub.presence_unsubscribe <string>(channel, DisplayReturnMessage);
                    break;

                case "8":
                    Console.WriteLine("Running time()");
                    pubnub.time <string>(DisplayReturnMessage);
                    break;

                default:
                    Console.WriteLine("INVALID CHOICE.");
                    break;
                }
            }

            Console.WriteLine("\nPress any key to confirm exit.\n\n");
            Console.ReadLine();
        }
예제 #36
0
        public void ThenOptionalSecretKeyShouldBeProvidedInConstructor()
        {
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    isPublished2 = false;
                    Pubnub pubnub = new Pubnub("demo", "demo", "key");
                    string channel = "my/channel";
                    string message = "Pubnub API Usage Example";

                    pubnub.publish<string>(channel, message, ReturnSecretKeyPublishCallback);
                    manualEvent2.WaitOne(310 * 1000);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                               {
                                   Assert.IsTrue(isPublished2, "Publish Failed with secret key");
                                   TestComplete();
                               });
                });
        }
예제 #37
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    isEncryptObjectPublished = false;
                    Pubnub pubnub = new Pubnub("demo", "demo", "", "enigma", false);
                    string channel = "my/channel";
                    object message = new SecretCustomClass();
                    messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);
                    

                    pubnub.publish<string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback);
                    mreEncryptObjectPub.WaitOne(310 * 1000);

                    if (!isEncryptObjectPublished)
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish Failed");
                           TestComplete();
                       });
                    }
                    else
                    {
                        pubnub.detailedHistory<string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback);
                        mreEncryptObjectDH.WaitOne(310 * 1000);
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(isEncryptObjectDH, "Unable to match the successful encrypt object Publish");
                           TestComplete();
                       });
                    }
                });
        }
예제 #38
0
        public static void TestUnencryptedHistory()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            string channel = "testchannel";
            //pubnub.CIPHER_KEY = "";

            deliveryStatus = false;
            string message = "Pubnub API Usage Example - Publish";

            pubnub.publish(channel, message, DisplayReturnMessage);
            while (!deliveryStatus) ;
            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
                if (e.PropertyName == "History")
                {
                    Console.WriteLine("\n*********** History Messages *********** ");
                    deliveryStatus = true;
                }
            };
            pubnub.history(channel, 1);

            deliveryStatus = false;

            while (!deliveryStatus) ;
            Console.WriteLine("\n*********** Publish *********** ");
            if (pubnub.History[0].Equals (null)) {
                Console.WriteLine("Null response");
            }
            else
            {
                Console.WriteLine(pubnub.History[0].ToString());
            }
        }
예제 #39
0
        public static void TestUnencryptedDetailedHistoryParams()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            string channel = "testchannel";

            int total_msg = 10;
            long starttime = Timestamp(pubnub);

            for (int i = 0; i < total_msg / 2; i++)
            {
                deliveryStatus = false;
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus) ;
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long midtime = Timestamp(pubnub);
            for (int i = total_msg / 2; i < total_msg; i++)
            {
                deliveryStatus = false;
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus) ;
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long endtime = Timestamp(pubnub);

            deliveryStatus = false;

            Console.WriteLine("DetailedHistory with start & end");
            pubnub.detailedHistory(channel, starttime, midtime, total_msg / 2, true, DisplayReturnMessage);
            while (!deliveryStatus) ;

            Console.WriteLine("DetailedHistory with start & reverse = true");
            string strResponse = "";
            if (objResponse.Equals(null))
            {
              Console.WriteLine("Null response");
            }
            else
            {
                IList<object> fields = objResponse as IList<object>;
                int j = 0;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if(j<total_msg/2)
                        Console.WriteLine(j.ToString(), strResponse);
                    j++;
                }
            }

            deliveryStatus = false;
            pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, true, DisplayReturnMessage);
            while (!deliveryStatus) ;

            Console.WriteLine("DetailedHistory with start & reverse = false");
            strResponse = "";
            if (objResponse.Equals(null))
            {
              Console.WriteLine("Null response");
            }
            else
            {
                IList<object> fields = objResponse as IList<object>;
                int j = total_msg / 2;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if(j<total_msg)
                        Console.WriteLine(j.ToString(), strResponse);
                    j++;
                }
            }

            deliveryStatus = false;
            pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, false, DisplayReturnMessage);
            while (!deliveryStatus) ;
            Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
            strResponse = "";
            if (objResponse.Equals(null))
            {
              Console.WriteLine("Null response");
            }
            else
            {
                IList<object> fields = objResponse as IList<object>;
                int j = 0;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if(j<total_msg/2)
                        Console.WriteLine(j.ToString(), strResponse);
                    j++;
                }
            }
        }
		public static void TestUnencryptedSecretDetailedHistoryParams()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"secretkey",
				"",
				false);
			string channel = "hello_world";
			
			//pubnub.CIPHER_KEY = "enigma";
			int total_msg = 10;
			Common cm = new Common();
			long starttime = cm.Timestamp(pubnub);
			cm.deliveryStatus = false;
			cm.objResponse = null;          
			
			for (int i = 0; i < total_msg / 2; i++)
			{
				cm.deliveryStatus = false;
				string msg = i.ToString();
				pubnub.publish(channel, msg, cm.DisplayReturnMessage);
				while (!cm.deliveryStatus) ;
				//long t = Timestamp();
				//inputs.Add(t, msg);
				Console.WriteLine("Message # " + i.ToString() + " published");
			}
			
			long midtime = cm.Timestamp(pubnub);
			for (int i = total_msg / 2; i < total_msg; i++)
			{
				cm.deliveryStatus = false;
				string msg = i.ToString();
				pubnub.publish(channel, msg, cm.DisplayReturnMessage);
				while (!cm.deliveryStatus) ;
				//long t = Timestamp();
				//inputs.Add(t, msg);
				Console.WriteLine("Message # " + i.ToString() + " published");
			}
			
			long endtime = cm.Timestamp(pubnub);
			
			PubnubUnitTest unitTest = new PubnubUnitTest();
			unitTest.TestClassName = "WhenDetailedHistoryIsRequested";
			unitTest.TestCaseName = "TestUnencryptedSecretDetailedHistoryParams1";
			
			pubnub.PubnubUnitTest = unitTest;
			
			cm.deliveryStatus = false;
			cm.objResponse = null;
			Console.WriteLine("DetailedHistory with start & end");
			pubnub.detailedHistory(channel, starttime, midtime, total_msg / 2, true, cm.DisplayReturnMessage);
			while (!cm.deliveryStatus) ;
			
			Console.WriteLine("DetailedHistory with start & reverse = true");
			string strResponse = "";
			if (cm.objResponse.Equals(null))
			{
				Assert.Fail("Null response");
			} 
			else
			{
				IList<object> fields = cm.objResponse as IList<object>;
				int j = 0;
				if (fields [0] != null)
				{
					var myObjectArray = (from item in fields select item as object).ToArray();
					IList<object> enumerable = myObjectArray [0] as IList<object>;
					if ((enumerable != null) && (enumerable.Count > 0))
					{
						foreach (object element in enumerable)
						{
							strResponse = element.ToString();
							Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
							if(j<total_msg/2)
								Assert.True(j.ToString().Equals(strResponse));
							j++;
						}
					}
					else
					{
						Assert.Fail("No response");
					}
				}            
			}  
			
			PubnubUnitTest unitTest2 = new PubnubUnitTest();
			unitTest2.TestClassName = "WhenDetailedHistoryIsRequested";
			unitTest2.TestCaseName = "TestUnencryptedSecretDetailedHistoryParams2";
			
			pubnub.PubnubUnitTest = unitTest2;
			
			cm.deliveryStatus = false;
			cm.objResponse = null;
			pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, true, cm.DisplayReturnMessage);
			while (!cm.deliveryStatus) ;
			
			Console.WriteLine("DetailedHistory with start & reverse = false");
			strResponse = "";
			if (cm.objResponse.Equals(null))
			{
				Assert.Fail("Null response");
			} 
			else
			{
				IList<object> fields = cm.objResponse as IList<object>;
				int j = total_msg / 2;
				if (fields [0] != null)
				{
					var myObjectArray = (from item in fields select item as object).ToArray();
					IList<object> enumerable = myObjectArray [0] as IList<object>;
					if ((enumerable != null) && (enumerable.Count > 0))
					{
						foreach (object element in enumerable)
						{
							strResponse = element.ToString();
							Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
							if(j<total_msg)
								Assert.True(j.ToString().Equals(strResponse));
							j++;
						}
					}
					else
					{
						Assert.Fail("No response");
					}
				}             
			}  
			
			
			PubnubUnitTest unitTest3 = new PubnubUnitTest();
			unitTest3.TestClassName = "WhenDetailedHistoryIsRequested";
			unitTest3.TestCaseName = "TestUnencryptedSecretDetailedHistoryParams3";
			
			pubnub.PubnubUnitTest = unitTest3;
			
			cm.deliveryStatus = false;
			cm.objResponse = null;
			pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, false, cm.DisplayReturnMessage);
			while (!cm.deliveryStatus) ;
			Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
			strResponse = "";
			if (cm.objResponse.Equals(null))
			{
				Assert.Fail("Null response");
			} 
			else
			{
				IList<object> fields = cm.objResponse as IList<object>;
				int j = 0;
				if (fields [0] != null)
				{
					var myObjectArray = (from item in fields select item as object).ToArray();
					IList<object> enumerable = myObjectArray [0] as IList<object>;
					if ((enumerable != null) && (enumerable.Count > 0))
					{
						foreach (object element in enumerable)
						{
							strResponse = element.ToString();
							Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
							if(j<total_msg/2)
								Assert.True(j.ToString().Equals(strResponse));
							j++;
						}
					}
					else
					{
						Assert.Fail("No response");
					}
				}             
			}  
		}
		public static void DetailedHistory_Decrypted_Example()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"enigma",
				false);
			string channel = "hello_world";
			//pubnub.CIPHER_KEY = "enigma";
			string msg = "Test Message";
			Common cm = new Common();
			
			
			cm.deliveryStatus = false;
			cm.objResponse = null;
			
			pubnub.publish(channel, msg, cm.DisplayReturnMessage);
			while (!cm.deliveryStatus) ;
			PubnubUnitTest unitTest = new PubnubUnitTest();
			unitTest.TestClassName = "WhenDetailedHistoryIsRequested";
			unitTest.TestCaseName = "DetailedHistory_Decrypted_Example";
			
			pubnub.PubnubUnitTest = unitTest;
			cm.deliveryStatus = false;
			cm.objResponse = null;
			pubnub.detailedHistory(channel, 1, cm.DisplayReturnMessage);
			while (!cm.deliveryStatus) ;
			Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
			
			if (cm.objResponse.Equals(null))
			{
				Assert.Fail("Null response");
			} 
			else
			{
				IList<object> fields = cm.objResponse as IList<object>;
				if (fields [0] != null)
				{
					var myObjectArray = (from item in fields select item as object).ToArray();
					
					IList<object> myObjectList = myObjectArray[0] as IList<object>;
					if (fields [0] != null)
					{
						Console.WriteLine("myObjectList[0]: " + myObjectList[0]);
						Assert.True(msg.Equals(myObjectList[0]));
					}
					else
					{
						Assert.Fail("NULL response");
					}
				}
			}  
		}
		public static void DetailedHistory_Example()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"",
				false);
			string channel = "hello_world";
			//pubnub.CIPHER_KEY = "";
			string msg = "Test Message";
			Common cm = new Common();
			cm.deliveryStatus = false;
			cm.objResponse = null;
			
			pubnub.publish(channel, msg, cm.DisplayReturnMessage);
			while (!cm.deliveryStatus) ;
			
			PubnubUnitTest unitTest = new PubnubUnitTest();
			unitTest.TestClassName = "WhenDetailedHistoryIsRequested";
			unitTest.TestCaseName = "DetailHistoryCount10ReturnsRecords";
			
			pubnub.PubnubUnitTest = unitTest;
			
			cm.deliveryStatus = false;
			cm.objResponse = null;
			
			pubnub.detailedHistory(channel, 10, cm.DisplayReturnMessage);
			while (!cm.deliveryStatus) ;
			Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
			
			if (cm.objResponse.Equals(null))
			{
				Assert.Fail("Null response");
			} 
			else
			{
				IList<object> fields = cm.objResponse as IList<object>;
				
				if (fields [0] != null)
				{
					var myObjectArray = (from item in fields select item as object).ToArray();
					IList<object> enumerable = myObjectArray [0] as IList<object>;
					if ((enumerable != null) && (enumerable.Count > 0))
					{
						foreach (object element in enumerable)
						{
							string strResponse = element.ToString();
							Console.WriteLine(String.Format("resp:{0}", strResponse));
							Assert.NotNull(strResponse);
						}
					}
					else
					{
						Assert.Fail("No response");
					}
				}
			}  
		}
예제 #43
0
        static void TestUnencryptedHistory()
        {
            pubnub.CIPHER_KEY       = "";
            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Publish")
                {
                    Console.WriteLine("\n*********** Publish Messages *********** ");
                    Console.WriteLine(
                        "Publish Success: " + ((Pubnub)sender).Publish[0].ToString() +
                        "\nPublish Info: " + ((Pubnub)sender).Publish[1].ToString()
                        );
                }

                if (e.PropertyName == "History")
                {
                    Console.WriteLine("\n*********** History Messages *********** ");
                    MessageFeeder(((Pubnub)sender).History);
                }
            };
            pubnub.publish(channel, message);
            pubnub.history(channel, 1);
        }
        public void DetailedHistoryStartWithReverseTrue()
        {
            expectedCountAtStartTimeWithReverseTrue = 0;
            msgStartReverseTrue = false;
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
                    string channel = "my/channel";
                    startTimeWithReverseTrue = Pubnub.translateDateTimeToPubnubUnixNanoSeconds(DateTime.UtcNow);
                    for (int index = 0; index < 10; index++)
                    {
                        pubnub.publish<string>(channel,
                            string.Format("DetailedHistoryStartTimeWithReverseTrue {0} {1}", startTimeWithReverseTrue, index),
                            DetailedHistorySamplePublishCallback);
                        mrePublishStartReverseTrue.WaitOne(5000);
                    }

                    Thread.Sleep(5000);

                    pubnub.detailedHistory<string>(channel, startTimeWithReverseTrue, DetailedHistoryStartWithReverseTrueCallback, true);
                    mreMsgStartReverseTrue.WaitOne(310 * 1000);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            Assert.IsTrue(msgStartReverseTrue, "Detailed History with Start and Reverse True Failed");
                            TestComplete();
                        });
                });
        }
예제 #45
0
        static public void Main()
        {
            Console.WriteLine("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
            Console.WriteLine("      DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
            Console.WriteLine("      RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
            Console.WriteLine();
            Console.WriteLine("      IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
            Console.WriteLine("      NETWORK ERROR MESSAGE WILL BE SENT");
            Console.WriteLine();

            Console.WriteLine("ENTER Channel Name");
            channel = Console.ReadLine();

            Console.WriteLine(string.Format("Channel = {0}", channel));
            Console.WriteLine();

            Console.WriteLine("Enable SSL? ENTER Y for Yes, else N");
            string enableSSL = Console.ReadLine();

            if (enableSSL.Trim().ToLower() == "y")
            {
                Console.WriteLine("SSL Enabled");
            }
            else
            {
                Console.WriteLine("SSL NOT Enabled");
            }
            Console.WriteLine();

            Console.WriteLine("ENTER cipher key for encryption feature.");
            Console.WriteLine("If you don't want to avail at this time, press ENTER.");
            string cipheryKey = Console.ReadLine();

            if (cipheryKey.Trim().Length > 0)
            {
                Console.WriteLine("Cipher key provided.");
            }
            else
            {
                Console.WriteLine("No Cipher key provided");
            }
            Console.WriteLine();

            pubnub = new Pubnub("demo", "demo", "", cipheryKey,
                                (enableSSL.Trim().ToLower() == "y") ? true : false);

            Console.WriteLine("ENTER 1 FOR Subscribe (not implementing connectCallback)");
            Console.WriteLine("ENTER 2 FOR Subscribe (implementing connectCallback)");
            Console.WriteLine("ENTER 3 FOR Publish");
            Console.WriteLine("ENTER 4 FOR Presence");
            Console.WriteLine("ENTER 5 FOR Detailed History");
            Console.WriteLine("ENTER 6 FOR Here_Now");
            Console.WriteLine("ENTER 7 FOR Unsubscribe");
            Console.WriteLine("ENTER 8 FOR Presence-Unsubscribe");
            Console.WriteLine("ENTER 9 FOR Time");
            Console.WriteLine("ENTER 0 FOR EXIT OR QUIT");

            bool exitFlag = false;

            Console.WriteLine("");
            while (!exitFlag)
            {
                string userinput = Console.ReadLine();
                switch (userinput)
                {
                case "0":
                    exitFlag = true;
                    pubnub.EndPendingRequests();
                    break;

                case "1":
                    Console.WriteLine("Running subscribe() (not implementing connectCallback)");
                    pubnub.subscribe <string>(channel, DisplayReturnMessage);
                    break;

                case "2":
                    Console.WriteLine("Running subscribe() (implementing connectCallback)");
                    pubnub.subscribe <string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage);
                    break;

                case "3":
                    Console.WriteLine("Running publish()");
                    Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
                    string publishMsg = Console.ReadLine();
                    double doubleData;
                    int    intData;
                    if (int.TryParse(publishMsg, out intData))                     //capture numeric data
                    {
                        pubnub.publish <string>(channel, intData, DisplayReturnMessage);
                    }
                    else if (double.TryParse(publishMsg, out doubleData))                     //capture numeric data
                    {
                        pubnub.publish <string>(channel, doubleData, DisplayReturnMessage);
                    }
                    else
                    {
                        //check whether any numeric is sent in double quotes
                        if (publishMsg.IndexOf("\"") == 0 && publishMsg.LastIndexOf("\"") == publishMsg.Length - 1)
                        {
                            string strMsg = publishMsg.Substring(1, publishMsg.Length - 2);
                            if (int.TryParse(strMsg, out intData))
                            {
                                pubnub.publish <string>(channel, strMsg, DisplayReturnMessage);
                            }
                            else if (double.TryParse(strMsg, out doubleData))
                            {
                                pubnub.publish <string>(channel, strMsg, DisplayReturnMessage);
                            }
                            else
                            {
                                pubnub.publish <string>(channel, publishMsg, DisplayReturnMessage);
                            }
                        }
                        else
                        {
                            pubnub.publish <string>(channel, publishMsg, DisplayReturnMessage);
                        }
                    }
                    break;

                case "4":
                    Console.WriteLine("Running presence()");
                    pubnub.presence <string>(channel, DisplayReturnMessage);
                    break;

                case "5":
                    Console.WriteLine("Running detailed history()");
                    pubnub.detailedHistory <string>(channel, 100, DisplayReturnMessage);
                    break;

                case "6":
                    Console.WriteLine("Running Here_Now()");
                    pubnub.here_now <string>(channel, DisplayReturnMessage);
                    break;

                case "7":
                    Console.WriteLine("Running unsubscribe()");
                    pubnub.unsubscribe <string>(channel, DisplayReturnMessage);
                    break;

                case "8":
                    Console.WriteLine("Running presence-unsubscribe()");
                    pubnub.presence_unsubscribe <string>(channel, DisplayReturnMessage);
                    break;

                case "9":
                    Console.WriteLine("Running time()");
                    pubnub.time <string>(DisplayReturnMessage);
                    break;

                default:
                    Console.WriteLine("INVALID CHOICE.");
                    break;
                }
            }

            Console.WriteLine("\nPress any key to exit.\n\n");
            Console.ReadLine();
        }
예제 #46
0
        public void ThenPublishKeyShouldBeOverriden()
        {
            Pubnub pubnub = new Pubnub(
                "",
                "demo",
                "",
                "",
                false
            );
            string channel = "mychannel";
            string message = "Pubnub API Usage Example";

            pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );
            Common cm = new Common();
            Assert.True((true).Equals(pubnub.publish(channel, message, cm.DisplayReturnMessage)));
        }
예제 #47
0
        public static void DetailedHistory_Example()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            string channel = "testchannel";
            //pubnub.CIPHER_KEY = "";
            string msg = "Test Message";
            deliveryStatus = false;
            pubnub.publish(channel, msg, DisplayReturnMessage);
            while (!deliveryStatus) ;

            deliveryStatus = false;
            pubnub.detailedHistory(channel, 10, DisplayReturnMessage);
            while (!deliveryStatus) ;
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");

            if (objResponse.Equals(null))
            {
              Console.WriteLine("Null response");
            }
            else
            {
                IList<object> fields = objResponse as IList<object>;

                foreach (object item in fields)
                {
                    string strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0}", strResponse));
                    Console.WriteLine(strResponse);
                }
            }
        }
예제 #48
0
        public void ThenPublishKeyShouldNotBeEmpty()
        {
            bool isExpectedException = false;
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub("", "demo", "", "", false);

                    string channel = "my/channel";
                    string message = "Pubnub API Usage Example";

                    try
                    {
                        pubnub.publish<string>(channel, message, null);
                    }
                    catch (MissingFieldException mfe)
                    {
                        isExpectedException = true;
                    }
                    catch (Exception ex)
                    {
                        isExpectedException = false;
                    }
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            Assert.IsTrue(isExpectedException);
                            TestComplete();
                        });
                });
        }
예제 #49
0
        public static void TestUnencryptedDetailedHistoryParams()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false);
            string channel = "testchannel";

            int  total_msg = 10;
            long starttime = Timestamp(pubnub);


            for (int i = 0; i < total_msg / 2; i++)
            {
                deliveryStatus = false;
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus)
                {
                    ;
                }
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long midtime = Timestamp(pubnub);

            for (int i = total_msg / 2; i < total_msg; i++)
            {
                deliveryStatus = false;
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus)
                {
                    ;
                }
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }


            long endtime = Timestamp(pubnub);

            deliveryStatus = false;

            Console.WriteLine("DetailedHistory with start & end");
            pubnub.detailedHistory(channel, starttime, midtime, total_msg / 2, true, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }

            Console.WriteLine("DetailedHistory with start & reverse = true");
            string strResponse = "";

            if (objResponse.Equals(null))
            {
                Console.WriteLine("Null response");
            }
            else
            {
                IList <object> fields = objResponse as IList <object>;
                int            j      = 0;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if (j < total_msg / 2)
                    {
                        Console.WriteLine(j.ToString(), strResponse);
                    }
                    j++;
                }
            }

            deliveryStatus = false;
            pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, true, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }

            Console.WriteLine("DetailedHistory with start & reverse = false");
            strResponse = "";
            if (objResponse.Equals(null))
            {
                Console.WriteLine("Null response");
            }
            else
            {
                IList <object> fields = objResponse as IList <object>;
                int            j      = total_msg / 2;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if (j < total_msg)
                    {
                        Console.WriteLine(j.ToString(), strResponse);
                    }
                    j++;
                }
            }


            deliveryStatus = false;
            pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, false, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
            strResponse = "";
            if (objResponse.Equals(null))
            {
                Console.WriteLine("Null response");
            }
            else
            {
                IList <object> fields = objResponse as IList <object>;
                int            j      = 0;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if (j < total_msg / 2)
                    {
                        Console.WriteLine(j.ToString(), strResponse);
                    }
                    j++;
                }
            }
        }
예제 #50
0
        public void IfSSLNotProvidedThenDefaultShouldBeFalse()
        {
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    isPublished3 = false;
                    Pubnub pubnub = new Pubnub("demo", "demo", "");
                    string channel = "my/channel";
                    string message = "Pubnub API Usage Example";

                    pubnub.publish<string>(channel, message, ReturnNoSSLDefaultFalseCallback);
                    manualEvent3.WaitOne(310 * 1000);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                               {
                                   Assert.IsTrue(isPublished3, "Publish Failed with no SSL");
                                   TestComplete();
                               });
                });
        }
예제 #51
0
        public static void TestEncryptedDetailedHistory()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "enigma",
                false);
            string channel = "testchannel";
            //pubnub.CIPHER_KEY = "enigma";

            int  total_msg = 10;
            long starttime = Timestamp(pubnub);
            Dictionary <long, string> inputs = new Dictionary <long, string>();

            for (int i = 0; i < total_msg / 2; i++)
            {
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus)
                {
                    ;
                }
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long midtime = Timestamp(pubnub);

            for (int i = total_msg / 2; i < total_msg; i++)
            {
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus)
                {
                    ;
                }
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long endtime = Timestamp(pubnub);

            while (!deliveryStatus)
            {
                ;
            }



            pubnub.detailedHistory(channel, total_msg, DisplayReturnMessage);
            deliveryStatus = false;
            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
            string strResponse = "";

            if (objResponse.Equals(null))
            {
                Console.WriteLine("Null response");
            }
            else
            {
                IList <object> fields = objResponse as IList <object>;
                int            j      = 0;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if (j < total_msg)
                    {
                        Console.WriteLine(j.ToString(), strResponse);
                    }
                    j++;
                }
            }
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
        }
예제 #52
0
        public static void TestEncryptedDetailedHistoryParams()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "enigma",
                false);
            // Context setup for Detailed Histor
            //pubnub.CIPHER_KEY = "enigma";
            int  total_msg = 10;
            long starttime = Timestamp(pubnub);

            for (int i = 0; i < total_msg / 2; i++)
            {
                deliveryStatus = false;
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus)
                {
                    ;
                }
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long midtime = Timestamp(pubnub);

            for (int i = total_msg / 2; i < total_msg; i++)
            {
                deliveryStatus = false;
                string msg = i.ToString();
                pubnub.publish(channel, msg, DisplayReturnMessage);
                while (!deliveryStatus)
                {
                    ;
                }
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }


            long endtime = Timestamp(pubnub);

            deliveryStatus          = false;
            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "DetailedHistory")
                {
                    Console.WriteLine("\n*********** DetailedHistory Messages *********** ");

                    /*foreach (object msg_org in (List<object>)((Pubnub)sender).DetailedHistory)
                     * {
                     *  Console.WriteLine(msg_org.ToString());
                     * }*/
                    deliveryStatus = true;
                }
            };
            Console.WriteLine("DetailedHistory with start & end");
            pubnub.detailedHistory(channel, starttime, midtime, total_msg / 2, true, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("DetailedHistory with start & reverse = true");
            deliveryStatus = false;
            pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, true, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("DetailedHistory with start & reverse = false");
            deliveryStatus = false;
            pubnub.detailedHistory(channel, midtime, -1, total_msg / 2, false, DisplayReturnMessage);
            while (!deliveryStatus)
            {
                ;
            }
            Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
        }
예제 #53
0
 public void ThenPublishKeyShouldNotBeEmptyAfterOverriden()
 {
     Pubnub pubnub = new Pubnub(
         "",
         "demo",
         "",
         "",
         false
     );
     string channel = "mychannel";
     string message = "Pubnub API Usage Example";
     Common cm = new Common();
     Assert.AreEqual(false, pubnub.publish(channel, message, cm.DisplayReturnMessage));
 }