本文整理汇总了C#中PubNub_Messaging.Pubnub.unsubscribe方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.unsubscribe方法的具体用法?C# Pubnub.unsubscribe怎么用?C# Pubnub.unsubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PubNub_Messaging.Pubnub
的用法示例。
在下文中一共展示了Pubnub.unsubscribe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThenPresenceShouldReturnReceivedMessage
public void ThenPresenceShouldReturnReceivedMessage()
{
receivedFlag1 = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
string channel = "my/channel";
pubnub.presence<string>(channel, ThenPresenceShouldReturnMessage);
//since presence expects from stimulus from sub/unsub...
pubnub.subscribe<string>(channel, DummyMethodForSubscribe);
manualEvent1.WaitOne(2000);
pubnub.unsubscribe<string>(channel, DummyMethodForUnSubscribe);
manualEvent3.WaitOne(2000);
manualEvent2.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedFlag1, "Presence message not received");
TestComplete();
});
});
}
示例2: 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();
}
示例3: SubscribeDemo
internal static void SubscribeDemo()
{
Pubnub pubnub = new Pubnub(
"demo",
"demo",
"",
"",
false);
string channel = "my_channel";
Console.WriteLine("Subscribe_Example");
pubnub.subscribe(channel, DisplayReturnMessage);
bool userexit = false;
while (!userexit)
{
Console.WriteLine("For Unsubscribe");
Console.WriteLine("Enter Y for UNSUBSCRIBE or ENTER X to EXIT subscribe loop");
string userinput = Console.ReadLine();
if (userinput.ToLower() == "y")
{
pubnub.unsubscribe(channel, DisplayReturnMessage);
userexit = true;
}
else if (userinput.ToLower() == "x")
{
userexit = true;
}
}
}