本文整理汇总了C#中Pubnub.WhereNow方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.WhereNow方法的具体用法?C# Pubnub.WhereNow怎么用?C# Pubnub.WhereNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.WhereNow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
int currentUserChoice = 0;
string userinput = "";
Console.WriteLine("");
while (!exitFlag)
{
if (currentUserChoice < 1 || (currentUserChoice > 40 && currentUserChoice != 99))
{
Console.WriteLine("ENTER 1 FOR Subscribe channel/channelgroup");
Console.WriteLine("ENTER 2 FOR Publish");
Console.WriteLine("ENTER 3 FOR Presence channel/channelgroup");
Console.WriteLine("ENTER 4 FOR Detailed History");
Console.WriteLine("ENTER 5 FOR Here_Now");
Console.WriteLine("ENTER 6 FOR Unsubscribe");
Console.WriteLine("ENTER 7 FOR Presence-Unsubscribe");
Console.WriteLine("ENTER 8 FOR Time");
Console.WriteLine("ENTER 9 FOR Disconnect/Reconnect existing Subscriber(s) (when internet is available)");
Console.WriteLine("ENTER 10 TO Disable Network Connection (no internet)");
Console.WriteLine("ENTER 11 TO Enable Network Connection (yes internet)");
Console.WriteLine("ENTER 12 FOR Grant Access to channel/ChannelGroup");
Console.WriteLine("ENTER 13 FOR Audit Access to channel/ChannelGroup");
Console.WriteLine("ENTER 14 FOR Revoke Access to channel/ChannelGroup");
Console.WriteLine("ENTER 15 FOR Grant Access to Presence Channel/ChannelGroup");
Console.WriteLine("ENTER 16 FOR Audit Access to Presence Channel/ChannelGroup");
Console.WriteLine("ENTER 17 FOR Revoke Access to Presence Channel/ChannelGroup");
Console.WriteLine("ENTER 18 FOR Change/Update Auth Key (Current value = {0})", pubnub.AuthenticationKey);
Console.WriteLine("ENTER 19 TO Simulate Machine Sleep Mode");
Console.WriteLine("ENTER 20 TO Simulate Machine Awake Mode");
Console.WriteLine("ENTER 21 TO Set Presence Heartbeat (Current value = {0} sec)", pubnub.PresenceHeartbeat);
Console.WriteLine("ENTER 22 TO Set Presence Heartbeat Interval (Current value = {0} sec)", pubnub.PresenceHeartbeatInterval);
Console.WriteLine("Enter 23 TO Set User State by Add/Modify Key-Pair");
Console.WriteLine("Enter 24 TO Set User State by Deleting existing Key-Pair");
Console.WriteLine("Enter 25 TO Set User State with direct json string");
Console.WriteLine("Enter 26 TO Get User State");
Console.WriteLine("Enter 27 FOR WhereNow");
Console.WriteLine("Enter 28 FOR GlobalHere_Now");
Console.WriteLine("Enter 29 TO change UUID. (Current value = {0})", pubnub.SessionUUID);
Console.WriteLine("Enter 38 FOR Channel Group - Add channel(s)");
Console.WriteLine("Enter 39 FOR Channel Group - Remove channel/group/namespace");
Console.WriteLine("Enter 40 FOR Channel Group - Get channel(s)/namespace(s)");
Console.WriteLine("ENTER 99 FOR EXIT OR QUIT");
userinput = Console.ReadLine();
}
switch (userinput)
{
case "99":
exitFlag = true;
pubnub.EndPendingRequests();
break;
case "1":
Console.WriteLine("Enter CHANNEL name for subscribe. Use comma to enter multiple channels.");
Console.WriteLine("NOTE: If you want to consider only Channel Group(s), just hit ENTER");
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 subscribe. Use comma to enter multiple channel groups.");
Console.WriteLine("To denote a namespaced CHANNEL GROUP, use the colon (:) character with the format namespace:channelgroup.");
Console.WriteLine("NOTE: If you want to consider only Channel(s), assuming you already entered , just hit ENTER");
channelGroup = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("Channel Group= {0}", channelGroup));
示例2: IfWhereNowIsCalledThenItShouldReturnInfo
public void IfWhereNowIsCalledThenItShouldReturnInfo()
{
mrePresence = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
string uuid = "hello_my_uuid";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
EnqueueCallback(() => pubnub.WhereNow<string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback));
mrePresence.WaitOne(310 * 1000);
EnqueueCallback(() => Assert.IsTrue(receivedWhereNowMessage, "where_now message not received"));
EnqueueTestComplete();
});
}
示例3: IfWhereNowIsCalledThenItShouldReturnInfo
public void IfWhereNowIsCalledThenItShouldReturnInfo()
{
ThreadPool.QueueUserWorkItem((s) =>
{
receivedWhereNowMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
string uuid = "hello_my_uuid";
mreWhereNow = new ManualResetEvent(false);
pubnub.WhereNow<string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
mreWhereNow.WaitOne(60 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
TestComplete();
});
});
}
示例4: IfWhereNowIsCalledThenItShouldReturnInfo
public void IfWhereNowIsCalledThenItShouldReturnInfo()
{
receivedWhereNowMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
string uuid = customUUID;
pubnub.WhereNow<string>(uuid, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
whereNowManualEvent.WaitOne();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
}
示例5: IfWhereNowIsCalledThenItShouldReturnInfo
public void IfWhereNowIsCalledThenItShouldReturnInfo()
{
receivedWhereNowMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = customUUID;
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfWhereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
whereNowChannel = "hello_my_channel";
subscribeManualEvent = new ManualResetEvent(false);
pubnub.Subscribe<string>(whereNowChannel, DummyMethodForSubscribe, SubscribeDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
whereNowManualEvent = new ManualResetEvent(false);
pubnub.WhereNow<string>(customUUID, ThenWhereNowShouldReturnMessage, DummyErrorCallback);
whereNowManualEvent.WaitOne();
if (!pubnub.PubnubUnitTest.EnableStubTest)
{
unsubscribeManualEvent = new ManualResetEvent(false);
pubnub.Unsubscribe<string>(whereNowChannel, DummyMethodForUnSubscribe, UnsubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
}
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedWhereNowMessage, "where_now message not received");
}
示例6: Main
//.........这里部分代码省略.........
int currentUserChoice = 0;
string userinput = "";
Console.WriteLine ("");
while (!exitFlag) {
if (currentUserChoice < 1 || (currentUserChoice > 30 && currentUserChoice != 99)) {
Console.WriteLine ("ENTER 1 FOR Subscribe");
Console.WriteLine ("ENTER 2 FOR Publish");
Console.WriteLine ("ENTER 3 FOR Presence");
Console.WriteLine ("ENTER 4 FOR Detailed History");
Console.WriteLine ("ENTER 5 FOR Here_Now");
Console.WriteLine ("ENTER 6 FOR Unsubscribe");
Console.WriteLine ("ENTER 7 FOR Presence-Unsubscribe");
Console.WriteLine ("ENTER 8 FOR Time");
Console.WriteLine ("ENTER 9 FOR Disconnect/Reconnect existing Subscriber(s) (when internet is available)");
Console.WriteLine ("ENTER 10 TO Disable Network Connection (no internet)");
Console.WriteLine ("ENTER 11 TO Enable Network Connection (yes internet)");
Console.WriteLine ("ENTER 12 FOR Grant Access");
Console.WriteLine ("ENTER 13 FOR Audit Access");
Console.WriteLine ("ENTER 14 FOR Revoke Access");
Console.WriteLine ("ENTER 15 FOR Grant Access for Presence Channel");
Console.WriteLine ("ENTER 16 FOR Audit Access for Presence Channel");
Console.WriteLine ("ENTER 17 FOR Revoke Access for Presence Channel");
Console.WriteLine ("ENTER 18 FOR Change/Update Auth Key (Current value = {0})", pubnub.AuthenticationKey);
Console.WriteLine ("ENTER 19 TO Simulate Machine Sleep Mode");
Console.WriteLine ("ENTER 20 TO Simulate Machine Awake Mode");
Console.WriteLine ("ENTER 21 TO Set Presence Heartbeat (Current value = {0} sec)", pubnub.PresenceHeartbeat);
Console.WriteLine ("ENTER 22 TO Set Presence Heartbeat Interval (Current value = {0} sec)", pubnub.PresenceHeartbeatInterval);
Console.WriteLine ("Enter 23 TO Add/Modify Local User State");
Console.WriteLine ("Enter 24 TO Delete Local User State");
Console.WriteLine ("Enter 25 TO View/Get Local User State");
Console.WriteLine ("Enter 26 TO Set User State");
Console.WriteLine ("Enter 27 TO Get User State");
Console.WriteLine ("Enter 28 FOR WhereNow");
Console.WriteLine ("Enter 29 FOR GlobalHere_Now");
Console.WriteLine ("Enter 30 TO change UUID. (Current value = {0})", pubnub.SessionUUID);
Console.WriteLine ("ENTER 99 FOR EXIT OR QUIT");
userinput = Console.ReadLine ();
}
switch (userinput) {
case "99":
exitFlag = true;
pubnub.EndPendingRequests ();
break;
case "1":
Console.WriteLine ("Enter CHANNEL name for subscribe. 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 subscribe()");
pubnub.Subscribe<string> (channel, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage);
//pubnub2.Subscribe<string>(channel, DisplaySubscribeReturnMessage, DisplaySubscribeConnectStatusMessage, DisplayErrorMessage);
//pubnub.Subscribe<object>(channel, (object o)=> {DisplayReturnMessage(o);}, (object o)=> {DisplayReturnMessage(o);}, DisplayErrorMessage);
break;
case "2":
Console.WriteLine ("Enter CHANNEL name for publish.");
channel = Console.ReadLine ();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("Channel = {0}", channel));