当前位置: 首页>>代码示例>>C#>>正文


C# Pubnub.Time方法代码示例

本文整理汇总了C#中Pubnub.Time方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.Time方法的具体用法?C# Pubnub.Time怎么用?C# Pubnub.Time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pubnub的用法示例。


在下文中一共展示了Pubnub.Time方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ThenWithProxyItShouldReturnTimeStamp

        public void ThenWithProxyItShouldReturnTimeStamp()
        {
            bool proxyConfigured = false;

            PubnubProxy proxy = new PubnubProxy();
            proxy.ProxyServer = "test.pandu.com";
            proxy.ProxyPort = 808;
            proxy.ProxyUserName = "tuvpnfreeproxy";
            proxy.ProxyPassword = "Rx8zW78k";

            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenGetRequestServerTime";
            unitTest.TestCaseName = "ThenWithProxyItShouldReturnTimeStamp";
            pubnub.PubnubUnitTest = unitTest;

            if (proxyConfigured)
            {
                pubnub.Proxy = proxy;
                pubnub.Time<string>(ReturnProxyPresenceTimeStampCallback, DummyErrorCallback);
                mreProxy.WaitOne(310 * 1000);
                pubnub.PubnubUnitTest = null;
                pubnub = null;
                Assert.IsTrue(timeReceivedWhenProxy, "time() Failed");
            }
            else
            {
                Assert.Ignore("Proxy setup not configured. After setup Set proxyConfigured to true");
            }
        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:31,代码来源:WhenGetRequestServerTime.cs

示例2: ThenWithProxyItShouldReturnTimeStamp

        public void ThenWithProxyItShouldReturnTimeStamp()
        {
            bool proxyConfigured = false;

            PubnubProxy proxy = new PubnubProxy();
            proxy.ProxyServer = "test.pandu.com";
            proxy.ProxyPort = 808;
            proxy.ProxyUserName = "tuvpnfreeproxy";
            proxy.ProxyPassword = "Rx8zW78k";

            pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenGetRequestServerTime";
            unitTest.TestCaseName = "ThenWithProxyItShouldReturnTimeStamp";
            pubnub.PubnubUnitTest = unitTest;
            
            if (proxyConfigured)
            {
                pubnub.Proxy = proxy;
                pubnub.Time<string>(ReturnProxyPresenceTimeStampCallback, DummyErrorCallback);
                mreProxy.WaitOne(310 * 1000, true);
                pubnub.EndPendingRequests(); 
                pubnub.PubnubUnitTest = null;
                pubnub = null;
                Assert.True(timeReceivedWhenProxy, "time() Failed");
            }
            else
            {
                Assert.That(!proxyConfigured);
            }

        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:33,代码来源:WhenGetRequestServerTime.cs

示例3: ThenItShouldReturnTimeStampSSL

        public void ThenItShouldReturnTimeStampSSL ()
        {
            Pubnub pubnub = new Pubnub (
                                Common.PublishKey,
                                Common.SubscribeKey,
                                "",
                                "",
                                true
                            );

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");
            ;

            string response = "";

            pubnub.Time (common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            IList<object> fields = common.Response as IList<object>;
            response = fields [0].ToString ();
            Console.WriteLine ("Response:" + response);
            Assert.AreNotEqual ("0", response);
            pubnub.EndPendingRequests ();
        }
开发者ID:hakangs,项目名称:c-sharp,代码行数:29,代码来源:WhenGetRequestServerTime.cs

示例4: ThenItShouldReturnTimeStamp

		public void ThenItShouldReturnTimeStamp()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"",
				false
				);
			
			Common common = new Common();
			common.DeliveryStatus = false;
			common.Response = null;
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");;
			
			string response = "";
			
			pubnub.Time(common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus) ;
			
			IList<object> fields = common.Response as IList<object>;
			response = fields[0].ToString();
			Console.WriteLine("Response:" + response);
			Assert.AreNotEqual("0",response);
		}
开发者ID:Vlanta,项目名称:c-sharp,代码行数:27,代码来源:WhenGetRequestServerTime.cs

示例5: Timestamp

        public long Timestamp(Pubnub pubnub)
        {
            DeliveryStatus = false;

            pubnub.Time(DisplayReturnMessage);
            while (!DeliveryStatus) ;

            IList<object> fields = Response as IList<object>;
            return Convert.ToInt64(fields[0].ToString());
        }
开发者ID:Vlanta,项目名称:c-sharp,代码行数:10,代码来源:Common.cs

示例6: ThenItShouldReturnTimeStamp

        public void ThenItShouldReturnTimeStamp()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                false
            );

            object timestamp = pubnub.Time();
            Assert.AreNotEqual(null, timestamp);
        }
开发者ID:inncapsule,项目名称:CSharpUrlEncodingFix,代码行数:12,代码来源:WhenGetRequestServerTime.cs

示例7: ThenItShouldReturnTimeStamp

        public void ThenItShouldReturnTimeStamp()
        {
            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenGetRequestServerTime";
            unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
            pubnub.PubnubUnitTest = unitTest;

            EnqueueCallback(() => pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback));
            EnqueueConditional(() => isTimeStamp);
            EnqueueCallback(() => Assert.IsTrue(timeReceived, "time() Failed"));
            EnqueueTestComplete();
        }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:13,代码来源:WhenGetRequestServerTime.cs

示例8: ThenItShouldReturnTimeStamp

        public void ThenItShouldReturnTimeStamp()
        {
            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenGetRequestServerTime";
            unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
            pubnub.PubnubUnitTest = unitTest;

            pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback);
            mreTime.WaitOne(310 * 1000);
            Assert.IsTrue(timeReceived, "time() Failed");
        }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:13,代码来源:WhenGetRequestServerTime.cs

示例9: ThenItShouldReturnTimeStamp

        public void ThenItShouldReturnTimeStamp()
        {
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenGetRequestServerTime";
            unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";

            pubnub.PubnubUnitTest = unitTest;

            pubnub.Time<string>(ReturnTimeStampCallback);
            mreTime.WaitOne(310 * 1000);
            UUnitAssert.True(timeReceived, "time() Failed");
        }
开发者ID:Vlanta,项目名称:c-sharp,代码行数:14,代码来源:WhenGetRequestServerTime.cs

示例10: ThenItShouldReturnTimeStamp

        public void ThenItShouldReturnTimeStamp()
        {
            mreTime = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
                    PubnubUnitTest unitTest = new PubnubUnitTest();
                    unitTest.TestClassName = "WhenGetRequestServerTime";
                    unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
                    pubnub.PubnubUnitTest = unitTest;

                    EnqueueCallback(() => pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback));
                    mreTime.WaitOne(310 * 1000);
                    EnqueueCallback(() => Assert.IsTrue(timeReceived, "time() Failed"));
                    EnqueueTestComplete();
                });
        }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:18,代码来源:WhenGetRequestServerTime.cs

示例11: Main

        static void Main(string[] args)
        {
            var myIp = GetExternalIp();
            // Start the HTML5 Pubnub client
            Process.Start(@"..\..\..\PubNub-HTML5-Client.html");

            System.Threading.Thread.Sleep(2000);

            Pubnub pubnub = new Pubnub(
                "pub-c-4331b990-8629-4f47-9669-51f0e2ee9c9d",               // PUBLISH_KEY
                "sub-c-bfd2fbba-0428-11e3-91de-02ee2ddab7fe",               // SUBSCRIBE_KEY
                "sec-c-NDExYTBlYjUtM2QyYS00YTJiLWExNDItM2Y5NDQ2ZjA1N2Uy",   // SECRET_KEY
                "",                                                         // CIPHER_KEY
                true                                                        // SSL_ON?
            );
            string channel = "ninja-channel";

            // Publish a sample message to Pubnub
            pubnub.Publish<string>(channel, "", DisplayReturnMessage);

            // Show PubNub server time
            pubnub.Time<string>(DisplayReturnMessage);
            //Console.WriteLine("Server Time: " + serverTime.ToString());

            // Subscribe for receiving messages (in a background task to avoid blocking)
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe<string>(
                    channel,
                    DisplayReturnMessage,
                    DisplayConnectStatusMessage
                )
            );
            t.Start();

            // Read messages from the console and publish them to Pubnub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string msg = Console.ReadLine();
                pubnub.Publish<string>(channel, myIp + " : " + msg, DisplayReturnMessage);
                Console.WriteLine("Message {0} sent.", msg);
            }
        }
开发者ID:saykorz,项目名称:TelerikAkademy,代码行数:44,代码来源:Program.cs

示例12: ThenItShouldReturnTimeStamp

        public void ThenItShouldReturnTimeStamp()
        {
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);

                    PubnubUnitTest unitTest = new PubnubUnitTest();
                    unitTest.TestClassName = "WhenGetRequestServerTime";
                    unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
                    pubnub.PubnubUnitTest = unitTest;

                    pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback);
                    mreTime.WaitOne(60 * 1000);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            Assert.IsTrue(timeReceived, "time() Failed");
                            TestComplete();
                        });
                });
        }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:20,代码来源:WhenGetRequestServerTime.cs

示例13: ThenWithProxyItShouldReturnTimeStamp

        public void ThenWithProxyItShouldReturnTimeStamp()
        {
            PubnubProxy proxy = new PubnubProxy();
            proxy.ProxyServer = "test.pandu.com";
            proxy.ProxyPort = 808;
            proxy.ProxyUserName = "tuvpnfreeproxy";
            proxy.ProxyPassword = "Rx8zW78k";

            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
            pubnub.Proxy = proxy;

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenGetRequestServerTime";
            unitTest.TestCaseName = "ThenWithProxyItShouldReturnTimeStamp";

            pubnub.PubnubUnitTest = unitTest;

            pubnub.Time<string>(ReturnProxyPresenceTimeStampCallback);
            mreProxy.WaitOne(310 * 1000);
            Assert.IsTrue(timeReceivedWhenProxy, "time() Failed");
        }
开发者ID:Vlanta,项目名称:c-sharp,代码行数:21,代码来源:WhenGetRequestServerTime.cs

示例14: Main

    public static void Main()
    {
        // -----------------
        // Init Pubnub Class
        // -----------------
        Pubnub pubnub = new Pubnub(
            "demo",  // PUBLISH_KEY
            "demo",  // SUBSCRIBE_KEY
            "",      // SECRET_KEY
            false    // SSL_ON?
        );
        string channel = "test-channel-顶";

        // ---------------
        // Publish Message
        // ---------------
        List<object> info = pubnub.Publish( channel, "Hello World" );

        // ----------------
        // Publish Response
        // ----------------
        Console.WriteLine(
            "Publish Success: " + info[0].ToString() +
            "\nPublish Info: "  + info[1]
        );

        // -------
        // History
        // -------
        List<object> history = pubnub.History( channel, 1 );
        foreach (object history_message in history) {
            Console.Write("History Message: ");
            Console.WriteLine(history_message);
        }

        // ----------------------
        // Get PubNub Server Time
        // ----------------------
        object timestamp = pubnub.Time();
        Console.WriteLine("Server Time: " + timestamp.ToString());

        // ---------
        // Subscribe
        // ---------
        pubnub.Subscribe(
            channel,
            delegate (object message) {
                Console.WriteLine("Received Message -> '" + message + "'");
                return true;
            }
        );
    }
开发者ID:jewer,项目名称:pubnub-api,代码行数:52,代码来源:Pubnub.cs

示例15: Main


//.........这里部分代码省略.........
            if (enableCustomUUID.Trim().ToLower() == "y")
            {
                Console.WriteLine("ENTER Session UUID.");
                string sessionUUID = Console.ReadLine();
                pubnub.SessionUUID = sessionUUID;
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Accepted Custom Session UUID.");
                Console.ResetColor();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Default Session UUID opted.");
                Console.ResetColor();
            }
            Console.WriteLine();

            Console.WriteLine("By default Resume On Reconnect is enabled. Do you want to disable it? ENTER Y for Yes, else N");
            string disableResumeOnReconnect = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            if (disableResumeOnReconnect.Trim().ToLower() == "y")
            {
                Console.WriteLine("Resume On Reconnect Disabled");
                pubnub.EnableResumeOnReconnect = false;
            }
            else
            {
                Console.WriteLine("Resume On Reconnect Enabled by default");
                pubnub.EnableResumeOnReconnect = true;
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Subscribe Timeout = 310 seconds (default). Enter the value to change, else press ENTER");
            string subscribeTimeoutEntry = Console.ReadLine();
            int subscribeTimeout;
            Int32.TryParse(subscribeTimeoutEntry, out subscribeTimeout);
            Console.ForegroundColor = ConsoleColor.Blue;
            if (subscribeTimeout > 0)
            {
                Console.WriteLine("Subscribe Timeout = {0}",subscribeTimeout);
                pubnub.SubscribeTimeout = subscribeTimeout;
            }
            else
            {
                Console.WriteLine("Subscribe Timeout = {0} (default)", pubnub.SubscribeTimeout);
            }
            Console.ResetColor();
            Console.WriteLine();

            Console.WriteLine("Non Subscribe Timeout = 15 seconds (default). Enter the value to change, else press ENTER");
            string nonSubscribeTimeoutEntry = Console.ReadLine();
            int nonSubscribeTimeout;
            Int32.TryParse(nonSubscribeTimeoutEntry, out nonSubscribeTimeout);
            Console.ForegroundColor = ConsoleColor.Blue;
            if (nonSubscribeTimeout > 0)
            {
                Console.WriteLine("Non Subscribe Timeout = {0}", nonSubscribeTimeout);
                pubnub.NonSubscribeTimeout = nonSubscribeTimeout;
            }
            else
            {
                Console.WriteLine("Non Subscribe Timeout = {0} (default)", pubnub.NonSubscribeTimeout);
            }
            Console.ResetColor();
            Console.WriteLine();
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:67,代码来源:PubnubExample.cs


注:本文中的Pubnub.Time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。