コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: Pubnub_Example.cs プロジェクト: twarnick/c-sharp
        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);
        }
コード例 #3
0
        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);
                }
            }*/
        }
コード例 #4
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());
            }
        }
コード例 #5
0
ファイル: Pubnub_Example.cs プロジェクト: Vlanta/c-sharp
 static void History_Example()
 {
     Pubnub pubnub = new Pubnub(
             "demo",
             "demo",
             "",
             false);
     string channel = "hello_world";
     
     pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
     {
         if (e.PropertyName == "History")
         {
             Console.WriteLine("\n*********** History Messages *********** ");
             MessageFeeder(((Pubnub)sender).History);
         }
     };
     pubnub.history(channel, 10);
 }
コード例 #6
0
        static void History_Example()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                false);
            string channel = "hello_world";

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "History")
                {
                    Console.WriteLine("\n*********** History Messages *********** ");
                    MessageFeeder(((Pubnub)sender).History);
                }
            };
            pubnub.history(channel, 10);
        }
コード例 #7
0
        static void History_Example()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    false);
            string channel = "my/channel";

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "History")
                {
                    foreach (object history_message in ((Pubnub)sender).History)
                    {
                        Console.WriteLine("History Message: ");
                        Dictionary<string, object> _messageHistory = (Dictionary<string, object>)(history_message);
                        Console.WriteLine(_messageHistory["text"]);
                    }
                }
            };
            pubnub.history(channel, 10);
        }
コード例 #8
0
        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()));
            }
        }
コード例 #9
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());
            }
        }