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


C# Pubnub.HereNow方法代码示例

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


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

示例1: HereNow

        void HereNow(Pubnub pubnub, string unitTestCaseName, 
                                            Action<object> userCallback)
        {
          string channel = "hello_world";

          PubnubUnitTest unitTest = new PubnubUnitTest();
          unitTest.TestClassName = "WhenAClientIsPresented";
          unitTest.TestCaseName = unitTestCaseName;
          pubnub.PubnubUnitTest = unitTest;

          pubnub.HereNow(channel, userCallback);
        }
开发者ID:Vlanta,项目名称:c-sharp,代码行数:12,代码来源:WhenAClientIsPresented.cs

示例2: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            receivedHereNowMessage = false;

            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest = unitTest;
            string channel = "hello_my_channel";
            pubnub.HereNow<string>(channel, ThenHereNowShouldReturnMessage, DummyErrorCallback);
            hereNowManualEvent.WaitOne();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
            Assert.IsTrue(receivedHereNowMessage, "here_now message not received");
        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:16,代码来源:WhenAClientIsPresented.cs

示例3: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            mrePresence = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
                    string channel = "hello_my_channel";

                    PubnubUnitTest unitTest = new PubnubUnitTest();
                    unitTest.TestClassName = "WhenAClientIsPresented";
                    unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
                    pubnub.PubnubUnitTest = unitTest;

                    EnqueueCallback(() => pubnub.HereNow<string>(channel, ThenHereNowShouldReturnMessage, DummyErrorCallback));
                    mrePresence.WaitOne(310 * 1000);
                    EnqueueCallback(() => Assert.IsTrue(receivedHereNowMessage, "here_now message not received"));
                    EnqueueTestComplete();
                });
        }
开发者ID:jonasduerto,项目名称:c-sharp,代码行数:19,代码来源:WhenAClientIsPresented.cs

示例4: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            receivedHereNowMessage = false;
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
                    string channel = "hello_my_channel";

                    PubnubUnitTest unitTest = new PubnubUnitTest();
                    unitTest.TestClassName = "WhenAClientIsPresented";
                    unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
                    pubnub.PubnubUnitTest = unitTest;

                    pubnub.HereNow<string>(channel, ThenHereNowShouldReturnMessage, DummyErrorCallback);
                    hereNowManualEvent.WaitOne();
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(receivedHereNowMessage, "here_now message not received");
                           TestComplete();
                       });
                });
        }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:22,代码来源:WhenAClientIsPresented.cs

示例5: ThenPresenceShouldReturnCustomUUID

        public void ThenPresenceShouldReturnCustomUUID()
        {
          Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
          
          Common commonHereNow = new Common();
          commonHereNow.DeliveryStatus = false;
          commonHereNow.Response = null;

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

          pubnub.PubnubUnitTest = commonHereNow.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnCustomUUID");;
          pubnub.SessionUUID = "CustomSessionUUIDTest";
          
          string channel = "hello_world";

          pubnub.Subscribe(channel, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessage);
            
          while (!commonSubscribe.DeliveryStatus);

          pubnub.HereNow<string>(channel, commonHereNow.DisplayReturnMessage);

          while (!commonHereNow.DeliveryStatus);
          if (commonHereNow.Response!= null)
          {
              object[] serializedMessage = JsonConvert.DeserializeObject<object[]>(commonHereNow.Response.ToString());
              JContainer dictionary = serializedMessage[0] as JContainer;
              var uuid = dictionary["uuids"].ToString();
              if (uuid != null)
              {
                  Assert.True(uuid.Contains(pubnub.SessionUUID));
              } else {
                  Assert.Fail("Custom uuid not found.");
              }
          } else {
              Assert.Fail("Null response");
          }
        }
开发者ID:Vlanta,项目名称:c-sharp,代码行数:39,代码来源:WhenAClientIsPresented.cs

示例6: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
            string channel = "hello_my_channel";

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest = unitTest;

            EnqueueCallback(() => pubnub.HereNow<string>(channel, ThenHereNowShouldReturnMessage, DummyErrorCallback));
            EnqueueConditional(() => hereNowReturnMessageCallbackInvoked);
            EnqueueCallback(() => Assert.IsTrue(receivedHereNowMessage, "here_now message not received"));
            EnqueueTestComplete();
        }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:15,代码来源:WhenAClientIsPresented.cs

示例7: Main


//.........这里部分代码省略.........
                            }
                            else
                            {
                                pubnub.Publish<string>(channel, publishMsg, DisplayReturnMessage, DisplayErrorMessage);
                            }
                        }
                        break;
                    case "3":
                        Console.WriteLine("Enter CHANNEL name for presence. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Presence Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running presence()");
                        pubnub.Presence<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage, DisplayErrorMessage);

                        break;
                    case "4":
                        Console.WriteLine("Enter CHANNEL name for Detailed History");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running detailed history()");
                        pubnub.DetailedHistory<string>(channel, 100, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "5":
                        Console.WriteLine("Enter CHANNEL name for HereNow");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running Here_Now()");
                        pubnub.HereNow<string>(channel, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "6":
                        Console.WriteLine("Enter CHANNEL name for Unsubscribe. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running unsubscribe()");
                        pubnub.Unsubscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage, DisplayDisconnectStatusMessage, DisplayErrorMessage);
                        break;
                    case "7":
                        Console.WriteLine("Enter CHANNEL name for Presence Unsubscribe. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running presence-unsubscribe()");
开发者ID:kaido42,项目名称:c-sharp,代码行数:67,代码来源:PubnubExample.cs

示例8: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            receivedHereNowMessage = false;

            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest = unitTest;
            string channel = "my/channel";
            pubnub.HereNow<string>(channel, ThenHereNowShouldReturnMessage);
            hereNowManualEvent.WaitOne();
            Assert.IsTrue(receivedHereNowMessage, "here_now message not received");
        }
开发者ID:ericflecher,项目名称:pubnub-api,代码行数:14,代码来源:WhenAClientIsPresented.cs

示例9: ThenPresenceShouldReturnCustomUUID

		public void ThenPresenceShouldReturnCustomUUID()
		{
			Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
			
			Common commonHereNow = new Common();
			commonHereNow.DeliveryStatus = false;
			commonHereNow.Response = null;
			
			Common commonSubscribe = new Common();
			commonSubscribe.DeliveryStatus = false;
			commonSubscribe.Response = null;
			
			pubnub.PubnubUnitTest = commonHereNow.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnCustomUUID");;
			pubnub.SessionUUID = "CustomSessionUUIDTest";
			
			string channel = "hello_world";
			
			pubnub.Subscribe(channel, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessage);
			
			while (!commonSubscribe.DeliveryStatus);
			
			pubnub.HereNow<string>(channel, commonHereNow.DisplayReturnMessage);
			
			while (!commonHereNow.DeliveryStatus);
			
			if (commonHereNow.Response == null) {
				Assert.Fail("Null response");
			}
			else
			{
				Assert.True(commonHereNow.Response.ToString().Contains(pubnub.SessionUUID));
			}          
		}
开发者ID:Vlanta,项目名称:c-sharp,代码行数:33,代码来源:WhenAClientIsPresented.cs

示例10: Main


//.........这里部分代码省略.........
                            }
                            else
                            {
                                pubnub.Publish<string>(channel, publishMsg, DisplayReturnMessage, DisplayErrorMessage);
                            }
                        }
                        break;
                    case "3":
                        Console.WriteLine("Enter CHANNEL name for presence. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Presence Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running presence()");
                        pubnub.Presence<string>(channel, DisplayPresenceReturnMessage, DisplayPresenceConnectStatusMessage, DisplayErrorMessage);

                        break;
                    case "4":
                        Console.WriteLine("Enter CHANNEL name for Detailed History");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running detailed history()");
                        pubnub.DetailedHistory<string>(channel, 100, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "5":
                        Console.WriteLine("Enter CHANNEL name for HereNow");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running Here_Now()");
                        pubnub.HereNow<string>(channel, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "6":
                        Console.WriteLine("Enter CHANNEL name for Unsubscribe. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running unsubscribe()");
                        pubnub.Unsubscribe<string>(channel, DisplayReturnMessage, DisplaySubscribeConnectStatusMessage, DisplaySubscribeDisconnectStatusMessage, DisplayErrorMessage);
                    /*pubnub.Unsubscribe<object>(channel, (object o) => {}
                    , (object o) => {}, (object o) => {}, (PubnubClientError e) => {});*/
                        break;
                    case "7":
                        Console.WriteLine("Enter CHANNEL name for Presence Unsubscribe. Use comma to enter multiple channels.");
                        channel = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Channel = {0}",channel));
                        Console.ResetColor();
                        Console.WriteLine();
开发者ID:TharinduMunasinge,项目名称:c-sharp,代码行数:67,代码来源:PubnubExample.cs

示例11: IfHereNowIsCalledThenItShouldReturnInfoWithUserState

        public void IfHereNowIsCalledThenItShouldReturnInfoWithUserState()
        {
            receivedHereNowMessage = false;
            currentTestCase = "IfHereNowIsCalledThenItShouldReturnInfoWithUserState";

            pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
            pubnub.SessionUUID = customUUID;
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfoWithUserState";
            pubnub.PubnubUnitTest = unitTest;
            
            string channel = "hello_my_channel";
            manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;

            subscribeManualEvent = new ManualResetEvent(false);
            pubnub.Subscribe<string>(channel, DummyMethodForSubscribe, SubscribeDummyMethodForConnectCallback, DummyErrorCallback);
            Thread.Sleep(1000);
            subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);

            userStateManualEvent = new ManualResetEvent(false);
            jsonUserState = "{\"testkey\":\"testval\"}";
            pubnub.SetUserState<string>(channel, jsonUserState, SetUserStateDummyMethodCallback, DummyErrorCallback);
            userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);

            hereNowManualEvent = new ManualResetEvent(false);
            pubnub.HereNow<string>(channel, true, true, ThenHereNowShouldReturnMessage, DummyErrorCallback);
            hereNowManualEvent.WaitOne(manualResetEventsWaitTimeout);

            unsubscribeManualEvent = new ManualResetEvent(false);
            pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe, UnsubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, DummyErrorCallback);
            Thread.Sleep(1000);
            unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);

            pubnub.EndPendingRequests();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
            Assert.IsTrue(receivedHereNowMessage, "here_now message not received with user state");
        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:39,代码来源:WhenAClientIsPresented.cs

示例12: IfHereNowIsCalledThenItShouldReturnInfoSecretSSL

        public void IfHereNowIsCalledThenItShouldReturnInfoSecretSSL()
        {
            receivedHereNowMessage = false;

            pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", true);
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
            pubnub.PubnubUnitTest = unitTest;
            
            string channel = "hello_my_channel";
            manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;

            subscribeManualEvent = new ManualResetEvent(false);
            pubnub.Subscribe<string>(channel, DummyMethodForSubscribe, SubscribeDummyMethodForConnectCallback, DummyErrorCallback);
            Thread.Sleep(1000);
            subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);

            hereNowManualEvent = new ManualResetEvent(false);
            pubnub.HereNow<string>(channel, ThenHereNowShouldReturnMessage, DummyErrorCallback);
            hereNowManualEvent.WaitOne(manualResetEventsWaitTimeout);

            unsubscribeManualEvent = new ManualResetEvent(false);
            pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe, UnsubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, DummyErrorCallback);
            Thread.Sleep(1000);
            unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);

            pubnub.EndPendingRequests();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
            Assert.IsTrue(receivedHereNowMessage, "here_now message not received ,with secret key, ssl");
        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:32,代码来源:WhenAClientIsPresented.cs

示例13: Main


//.........这里部分代码省略.........
							//pubnub2.Publish<string>(channel, publishMsg, DisplayReturnMessage, DisplayErrorMessage);
						}
					}
					break;
				case "3":
					Console.WriteLine ("Enter CHANNEL name for presence. Use comma to enter multiple channels.");
					channel = Console.ReadLine ();

					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Presence Channel = {0}", channel));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running presence()");
					pubnub.Presence<string> (channel, DisplayPresenceReturnMessage, DisplayPresenceConnectStatusMessage, DisplayErrorMessage);

					break;
				case "4":
					Console.WriteLine ("Enter CHANNEL name for Detailed History");
					channel = Console.ReadLine ();

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

					Console.WriteLine ("Running detailed history()");
					pubnub.DetailedHistory<string> (channel, 100, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "5":
					bool showUUID = true;
					bool includeUserState = false;

					Console.WriteLine ("Enter CHANNEL name for HereNow");
					channel = Console.ReadLine ();

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

					Console.WriteLine ("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
					string userChoiceShowUUID = Console.ReadLine ();
					if (userChoiceShowUUID.ToLower () == "n") {
						showUUID = false;
					}
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Show UUID = {0}", showUUID));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
					string userChoiceIncludeUserState = Console.ReadLine ();
					if (userChoiceIncludeUserState.ToLower () == "y") {
						includeUserState = true;
					}
					Console.ForegroundColor = ConsoleColor.Blue;
					Console.WriteLine (string.Format ("Include User State = {0}", includeUserState));
					Console.ResetColor ();
					Console.WriteLine ();

					Console.WriteLine ("Running Here_Now()");
					pubnub.HereNow<string> (channel, showUUID, includeUserState, DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "6":
					Console.WriteLine ("Enter CHANNEL name for Unsubscribe. Use comma to enter multiple channels.");
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:67,代码来源:PubnubExample.cs

示例14: Main


//.........这里部分代码省略.........
			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.HereNow<string>(channel, DisplayReturnMessage);
					break;
				case "7":
					Console.WriteLine("Running unsubscribe()");
					pubnub.Unsubscribe<string>(channel, DisplayReturnMessage);
					break;
				case "8":
					Console.WriteLine("Running presence-unsubscribe()");
					pubnub.PresenceUnsubscribe<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();
			
		}
开发者ID:Vlanta,项目名称:c-sharp,代码行数:101,代码来源:Pubnub_Example.cs

示例15: Main


//.........这里部分代码省略.........
                        channelGroup = Console.ReadLine();

                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Presence Channel Group= {0}", channelGroup));
                        Console.ResetColor();
                        Console.WriteLine();

                        if (channel.Length <= 0 && channelGroup.Length <= 0)
                        {
                            Console.WriteLine("To run presence(), atleast provide either channel name or channel group name or both");
                        }
                        else
                        {
                            Console.WriteLine("Running presence()");
                            pubnub.Presence<string>(channel, channelGroup, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage);
                        }
                        break;
                    case "4":
                        Console.WriteLine("Enter CHANNEL name for Detailed History");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Running detailed history()");
                        pubnub.DetailedHistory<string>(channel, 100, DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "5":
                        bool showUUID = true;
                        bool includeUserState = false;

                        Console.WriteLine("Enter CHANNEL name for HereNow");
                        channel = Console.ReadLine();

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

                        Console.WriteLine("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
                        string userChoiceShowUUID = Console.ReadLine();
                        if (userChoiceShowUUID.ToLower() == "n")
                        {
                            showUUID = false;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Show UUID = {0}",showUUID));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
                        string userChoiceIncludeUserState = Console.ReadLine();
                        if (userChoiceIncludeUserState.ToLower() == "y")
                        {
                            includeUserState = true;
                        }
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("Include User State = {0}", includeUserState));
                        Console.ResetColor();
                        Console.WriteLine();

                        Console.WriteLine("Running Here_Now()");
                        pubnub.HereNow<string>(channel, showUUID, includeUserState, DisplayReturnMessage, DisplayErrorMessage);
                        break;
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:67,代码来源:PubnubExample.cs


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