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


C# Pubnub.PresenceUnsubscribe方法代码示例

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


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

示例1: ThenPresenceShouldReturnReceivedMessage

        public void ThenPresenceShouldReturnReceivedMessage()
        {
            receivedPresenceMessage = false;

            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
            
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAClientIsPresented";
            unitTest.TestCaseName = "ThenPresenceShouldReturnReceivedMessage";
            pubnub.PubnubUnitTest = unitTest;
            
            string channel = "my/channel";

            pubnub.Presence<string>(channel, ThenPresenceShouldReturnMessage);

            //since presence expects from stimulus from sub/unsub...
            pubnub.Subscribe<string>(channel, DummyMethodForSubscribe);
            subscribeManualEvent.WaitOne(2000);

            pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe);
            unsubscribeManualEvent.WaitOne(2000);

            presenceManualEvent.WaitOne(310 * 1000);

            pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSub);
            presenceUnsubscribeEvent.WaitOne();
            
            Assert.IsTrue(receivedPresenceMessage, "Presence message not received");
        }
开发者ID:ericflecher,项目名称:pubnub-api,代码行数:29,代码来源:WhenAClientIsPresented.cs

示例2: ThenPresenceShouldReturnReceivedMessage

        public void ThenPresenceShouldReturnReceivedMessage()
        {
            receivedPresenceMessage = false;
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
                    string channel = "my/channel";

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

                    pubnub.Presence<string>(channel, ThenPresenceShouldReturnMessage);

                    //since presence expects from stimulus from sub/unsub...
                    pubnub.Subscribe<string>(channel, DummyMethodForSubscribe);
                    subscribeManualEvent.WaitOne(2000);

                    pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe);
                    unsubscribeManualEvent.WaitOne(2000);

                    pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSub);
                    presenceUnsubscribeEvent.WaitOne(2000);

                    presenceManualEvent.WaitOne(310 * 1000);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(receivedPresenceMessage, "Presence message not received");
                           TestComplete();
                       });
                });
        }
开发者ID:ericflecher,项目名称:pubnub-api,代码行数:33,代码来源:WhenAClientIsPresented.cs

示例3: Main


//.........这里部分代码省略.........
                        if (channel.Length <= 0 && channelGroup.Length <= 0)
                        {
                            Console.WriteLine("To run unsubscribe(), atleast provide either channel name or channel group name or both");
                        }
                        else
                        {
                            Console.WriteLine("Running unsubscribe()");
                            pubnub.Unsubscribe<string>(channel, channelGroup, DisplayReturnMessage, DisplaySubscribeConnectStatusMessage, DisplaySubscribeDisconnectStatusMessage, 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("Enter channel group name for Presence Unsubscribe");
                        Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
                        channelGroup = Console.ReadLine();
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine(string.Format("ChannelGroup = {0}", channelGroup));
                        Console.ResetColor();

                        if (channel.Length <= 0 && channelGroup.Length <= 0)
                        {
                            Console.WriteLine("To run presence-unsubscribe(), atleast provide either channel name or channel group name or both");
                        }
                        else
                        {
                            Console.WriteLine("Running presence-unsubscribe()");
                            pubnub.PresenceUnsubscribe<string>(channel, channelGroup, DisplayReturnMessage, DisplayPresenceConnectStatusMessage, DisplayPresenceDisconnectStatusMessage, DisplayErrorMessage);
                        }
                        break;
                    case "8":
                        Console.WriteLine("Running time()");
                        pubnub.Time<string>(DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "9":
                        Console.WriteLine("Running Disconnect/auto-Reconnect Subscriber Request Connection");
                        pubnub.TerminateCurrentSubscriberRequest();
                        break;
                    case "10":
                        Console.WriteLine("Disabling Network Connection (no internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Initiating Simulation of Internet non-availability");
                        Console.WriteLine("Until Choice=11 is entered, no operations will occur");
                        Console.WriteLine("NOTE: Publish from other pubnub clients can occur and those will be ");
                        Console.WriteLine("      captured upon choice=11 is entered provided resume on reconnect is enabled.");
                        Console.ResetColor();
                        pubnub.EnableSimulateNetworkFailForTestingOnly();
                        break;
                    case "11":
                        Console.WriteLine("Enabling Network Connection (yes internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Stopping Simulation of Internet non-availability");  
                        Console.ResetColor();
                        pubnub.DisableSimulateNetworkFailForTestingOnly();
                        break;
                    case "12":
                        Console.WriteLine("Enter CHANNEL name for PAM Grant. For Presence, Select Option 15.");
                        Console.WriteLine("To enter CHANNEL GROUP name, just hit ENTER");
                        channel = Console.ReadLine();
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:66,代码来源:PubnubExample.cs

示例4: Main


//.........这里部分代码省略.........
                                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()");
                        pubnub.PresenceUnsubscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage, DisplayDisconnectStatusMessage, DisplayErrorMessage);
                        break;
                    case "8":
                        Console.WriteLine("Running time()");
                        pubnub.Time<string>(DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "9":
                        Console.WriteLine("Running Disconnect/auto-Reconnect Subscriber Request Connection");
                        pubnub.TerminateCurrentSubscriberRequest();
                        break;
                    case "10":
                        Console.WriteLine("Disabling Network Connection (no internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Initiating Simulation of Internet non-availability");
                        Console.WriteLine("Until Choice=11 is entered, no operations will occur");
                        Console.WriteLine("NOTE: Publish from other pubnub clients can occur and those will be ");
                        Console.WriteLine("      captured upon choice=11 is entered provided resume on reconnect is enabled.");
                        Console.ResetColor();
                        pubnub.EnableSimulateNetworkFailForTestingOnly();
                        break;
                    case "11":
                        Console.WriteLine("Enabling Network Connection (yes internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Stopping Simulation of Internet non-availability");
                        Console.ResetColor();
                        pubnub.DisableSimulateNetworkFailForTestingOnly();
                        break;
                    default:
                        Console.WriteLine("INVALID CHOICE. ENTER 99 FOR EXIT OR QUIT");
                        break;
                }
            }

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

        }
开发者ID:kaido42,项目名称:c-sharp,代码行数:101,代码来源:PubnubExample.cs

示例5: ThenPresenceShouldReturnCustomUUID

        public void ThenPresenceShouldReturnCustomUUID()
        {
            receivedCustomUUID = false;

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

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

            string channel = "my/channel";

            pubnub.Presence<string>(channel, ThenPresenceWithCustomUUIDShouldReturnMessage);

            //since presence expects from stimulus from sub/unsub...
            pubnub.SessionUUID = customUUID;
            pubnub.Subscribe<string>(channel, DummyMethodForSubscribeUUID);
            subscribeUUIDManualEvent.WaitOne(2000);

            pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribeUUID);
            unsubscribeUUIDManualEvent.WaitOne(2000);

            presenceUUIDManualEvent.WaitOne(310 * 1000);

            pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSubUUID);
            presenceUnsubscribeUUIDEvent.WaitOne();

            Assert.IsTrue(receivedCustomUUID, "Custom UUID not received");
        }
开发者ID:ericflecher,项目名称:pubnub-api,代码行数:30,代码来源:WhenAClientIsPresented.cs

示例6: Main


//.........这里部分代码省略.........

                        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();

                        Console.WriteLine("Running presence-unsubscribe()");
                        pubnub.PresenceUnsubscribe<string>(channel, DisplayReturnMessage, DisplayPresenceConnectStatusMessage, DisplayPresenceDisconnectStatusMessage, DisplayErrorMessage);
                        break;
                    case "8":
                        Console.WriteLine("Running time()");
                        pubnub.Time<string>(DisplayReturnMessage, DisplayErrorMessage);
                        break;
                    case "9":
                        Console.WriteLine("Running Disconnect/auto-Reconnect Subscriber Request Connection");
                        pubnub.TerminateCurrentSubscriberRequest();
                        break;
                    case "10":
                        Console.WriteLine("Disabling Network Connection (no internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Initiating Simulation of Internet non-availability");
                        Console.WriteLine("Until Choice=11 is entered, no operations will occur");
                        Console.WriteLine("NOTE: Publish from other pubnub clients can occur and those will be ");
                        Console.WriteLine("      captured upon choice=11 is entered provided resume on reconnect is enabled.");
                        Console.ResetColor();
                        pubnub.EnableSimulateNetworkFailForTestingOnly();
                        break;
                    case "11":
                        Console.WriteLine("Enabling Network Connection (yes internet)");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Stopping Simulation of Internet non-availability");  
                        Console.ResetColor();
                        pubnub.DisableSimulateNetworkFailForTestingOnly();
                        break;
                    case "12":
                        Console.WriteLine("Enter CHANNEL name for PAM Grant. For Presence, Select Option 15.");
                        channel = Console.ReadLine();
                        Console.WriteLine("Read Access? Enter Y for Yes (default), N for No.");
                        string readAccess = Console.ReadLine();
                        bool read = (readAccess.ToLower() == "n") ? false : true;
开发者ID:TharinduMunasinge,项目名称:c-sharp,代码行数:67,代码来源:PubnubExample.cs

示例7: Main


//.........这里部分代码省略.........
					}
					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.");
					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 ();

					Console.WriteLine ("Running presence-unsubscribe()");
					pubnub.PresenceUnsubscribe<string> (channel, DisplayReturnMessage, DisplayPresenceConnectStatusMessage, DisplayPresenceDisconnectStatusMessage, DisplayErrorMessage);
					break;
				case "8":
					Console.WriteLine ("Running time()");
					pubnub.Time<string> (DisplayReturnMessage, DisplayErrorMessage);
					break;
				case "9":
					Console.WriteLine ("Running Disconnect/auto-Reconnect Subscriber Request Connection");
					pubnub.TerminateCurrentSubscriberRequest ();
					break;
				case "10":
					Console.WriteLine ("Disabling Network Connection (no internet)");
					Console.ForegroundColor = ConsoleColor.Red;
					Console.WriteLine ("Initiating Simulation of Internet non-availability");
					Console.WriteLine ("Until Choice=11 is entered, no operations will occur");
					Console.WriteLine ("NOTE: Publish from other pubnub clients can occur and those will be ");
					Console.WriteLine ("      captured upon choice=11 is entered provided resume on reconnect is enabled.");
					Console.ResetColor ();
					pubnub.EnableSimulateNetworkFailForTestingOnly ();
					break;
				case "11":
					Console.WriteLine ("Enabling Network Connection (yes internet)");
					Console.ForegroundColor = ConsoleColor.Red;
					Console.WriteLine ("Stopping Simulation of Internet non-availability");  
					Console.ResetColor ();
					pubnub.DisableSimulateNetworkFailForTestingOnly ();
					break;
				case "12":
					Console.WriteLine ("Enter CHANNEL name for PAM Grant. For Presence, Select Option 15.");
					channel = Console.ReadLine ();
					Console.WriteLine ("Read Access? Enter Y for Yes (default), N for No.");
					string readAccess = Console.ReadLine ();
					bool read = (readAccess.ToLower () == "n") ? false : true;
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:67,代码来源:PubnubExample.cs

示例8: 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


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