當前位置: 首頁>>代碼示例>>C#>>正文


C# Pubnub.here_now方法代碼示例

本文整理匯總了C#中PubNub_Messaging.Pubnub.here_now方法的典型用法代碼示例。如果您正苦於以下問題:C# Pubnub.here_now方法的具體用法?C# Pubnub.here_now怎麽用?C# Pubnub.here_now使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PubNub_Messaging.Pubnub的用法示例。


在下文中一共展示了Pubnub.here_now方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: HereNow_Example

        static void HereNow_Example()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    false);
            //string channel = "hello_world";
            string channel = "hello_world";

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Here_Now")
                {
                    Console.WriteLine("\n********** Here Now Messages *********** ");
                    Dictionary<string, object> _message = (Dictionary<string, object>)(((Pubnub)sender).Here_Now[0]);
                    foreach (object uuid in (object[])_message["uuids"])
                    {
                        Console.WriteLine("UUID: " + uuid.ToString());
                    }
                    Console.WriteLine("Occupancy: " + _message["occupancy"].ToString());
                }
            };
            pubnub.here_now(channel);
        }
開發者ID:netcon-source,項目名稱:pubnub-api,代碼行數:25,代碼來源:Pubnub_Example.cs

示例2: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            Pubnub pubnub = new Pubnub(
               "demo",
               "demo",
               "",
               "",
               false
           );
            string channel = "hello_world";
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest = unitTest;

            Common cm = new Common();
            cm.deliveryStatus = false;
            cm.objResponse = null;
            pubnub.here_now(channel, 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 lst in fields)
                {
                    strResponse = lst.ToString();
                    Console.WriteLine("Resp:" + strResponse);
                    Assert.IsNotEmpty(strResponse);
                }
                Dictionary<string, object> message = (Dictionary<string, object>)fields[0];
                foreach(KeyValuePair<String, object> entry in message)
                {
                    Console.WriteLine("value:" + entry.Value + "  " + "key:" + entry.Key);
                }

                /*object[] objUuid = (object[])message["uuids"];
                foreach (object obj in objUuid)
                {
                    Console.WriteLine(obj.ToString()); 
                }*/
                //Assert.AreNotEqual(0, message["occupancy"]);
            }

        }
開發者ID:stjom,項目名稱:pubnub-api,代碼行數:49,代碼來源:WhenAClientIsPresented.cs

示例3: Here_Now_Demo

        internal static void Here_Now_Demo()
        {
            Pubnub pubnub = new Pubnub(
                        "demo",
                        "demo",
                        "",
                        "",
                        false);

            string channel = "my/channel";

            Console.WriteLine("Here_Now_Example");

            pubnub.here_now<string>(channel, DisplayReturnMessage);
        }
開發者ID:netcon-source,項目名稱:pubnub-api,代碼行數:15,代碼來源:Here_Now_Example.cs

示例4: Main


//.........這裏部分代碼省略.........
            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();

        }
開發者ID:sevco777,項目名稱:pubnub-api,代碼行數:101,代碼來源:Pubnub_Example.cs

示例5: IfHereNowIsCalledThenItShouldReturnInfo

 public void IfHereNowIsCalledThenItShouldReturnInfo()
 {
     receivedFlag2 = false;
     ThreadPool.QueueUserWorkItem((s) =>
         {
             Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
             string channel = "my/channel";
             pubnub.here_now<string>(channel, ThenHereNowShouldReturnMessage);
             manualEvent4.WaitOne();
             Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    Assert.IsTrue(receivedFlag2, "here_now message not received");
                    TestComplete();
                });
         });
 }
開發者ID:hart404,項目名稱:pubnub-api,代碼行數:16,代碼來源:WhenAClientIsPresented.cs

示例6: HereNow_Example

        public static void HereNow_Example()
        {
            Pubnub pubnub = new Pubnub(
               "demo",
               "demo",
               "",
               "",
               false
               );
            string channel = "hello_world";

            deliveryStatus = false;

            pubnub.here_now(channel, DisplayReturnMessage);
            while (!deliveryStatus) ;

            string strResponse = "";
            if (objResponse.Equals (null)) {
                Console.WriteLine("Null response");
            }
            else
            {
                IList<object> fields =objResponse as IList<object>;
                foreach(object lst in fields)
                {
                    strResponse = lst.ToString();
                    Console.WriteLine(strResponse);
                }
                Dictionary<string, object> message = (Dictionary<string, object>)fields[0];
                foreach(KeyValuePair<String, object> entry in message)
                {
                    Console.WriteLine("value:" + entry.Value + "  " + "key:" + entry.Key);
                }

                object[] objUuid = (object[])message["uuids"];
                foreach (object obj in objUuid)
                {
                    Console.WriteLine(obj.ToString());
                }
            }
        }
開發者ID:netcon-source,項目名稱:pubnub-api,代碼行數:41,代碼來源:PubNub-Example2.cs


注:本文中的PubNub_Messaging.Pubnub.here_now方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。