本文整理汇总了C#中Pubnub.GlobalHereNow方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.GlobalHereNow方法的具体用法?C# Pubnub.GlobalHereNow怎么用?C# Pubnub.GlobalHereNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.GlobalHereNow方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IfGlobalHereNowIsCalledThenItShouldReturnInfo
public void IfGlobalHereNowIsCalledThenItShouldReturnInfo()
{
ThreadPool.QueueUserWorkItem((s) =>
{
receivedGlobalHereNowMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfGlobalHereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
mreGlobalHereNow = new ManualResetEvent(false);
pubnub.GlobalHereNow<string>(true, true, ThenGlobalHereNowShouldReturnMessage, DummyErrorCallback);
mreGlobalHereNow.WaitOne(60 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedGlobalHereNowMessage, "global_here_now message not received");
pubnub.PubnubUnitTest = null;
pubnub = null;
TestComplete();
});
});
}
示例2: IfGlobalHereNowIsCalledThenItShouldReturnInfo
public void IfGlobalHereNowIsCalledThenItShouldReturnInfo()
{
receivedGlobalHereNowMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfGlobalHereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
pubnub.GlobalHereNow<string>(true, true, ThenGlobalHereNowShouldReturnMessage, DummyErrorCallback);
globalHereNowManualEvent.WaitOne();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedGlobalHereNowMessage, "global_here_now message not received");
}
示例3: IfGlobalHereNowIsCalledThenItShouldReturnInfo
public void IfGlobalHereNowIsCalledThenItShouldReturnInfo()
{
mrePresence = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfGlobalHereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
EnqueueCallback(() => pubnub.GlobalHereNow<string>(true, true, ThenGlobalHereNowShouldReturnMessage, DummyErrorCallback));
mrePresence.WaitOne(310 * 1000);
EnqueueCallback(() => Assert.IsTrue(receivedGlobalHereNowMessage, "global_here_now message not received"));
EnqueueCallback(() =>
{
pubnub.PubnubUnitTest = null;
pubnub = null;
}
);
EnqueueTestComplete();
});
}
示例4: Main
//.........这里部分代码省略.........
string setUserStateChannelGroup2 = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("ChannelGroup = {0}", setUserStateChannelGroup2));
Console.ResetColor();
Console.WriteLine("Enter UUID. (Optional. Press ENTER to skip it)");
string uuid2 = Console.ReadLine();
if (string.IsNullOrEmpty(uuid2))
{
pubnub.GetUserState<string>(getUserStateChannel2, setUserStateChannelGroup2, DisplayReturnMessage, DisplayErrorMessage);
}
else
{
pubnub.GetUserState<string>(getUserStateChannel2, setUserStateChannelGroup2, uuid2, DisplayReturnMessage, DisplayErrorMessage);
}
break;
case "27":
Console.WriteLine("Enter uuid for WhereNow. To consider SessionUUID, just press ENTER");
string whereNowUuid = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("uuid = {0}", whereNowUuid));
Console.ResetColor();
Console.WriteLine();
Console.WriteLine("Running Where_Now()");
pubnub.WhereNow<string>(whereNowUuid, DisplayReturnMessage, DisplayErrorMessage);
break;
case "28":
bool globalHereNowShowUUID = true;
bool globalHereNowIncludeUserState = false;
Console.WriteLine("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
string userChoiceGlobalHereNowShowUUID = Console.ReadLine();
if (userChoiceGlobalHereNowShowUUID.ToLower() == "n")
{
globalHereNowShowUUID = false;
}
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("Show UUID = {0}", globalHereNowShowUUID));
Console.ResetColor();
Console.WriteLine();
Console.WriteLine("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
string userChoiceGlobalHereNowIncludeUserState = Console.ReadLine();
if (userChoiceGlobalHereNowIncludeUserState.ToLower() == "y")
{
globalHereNowIncludeUserState = true;
}
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("Include User State = {0}", globalHereNowIncludeUserState));
Console.ResetColor();
Console.WriteLine();
Console.WriteLine("Running Global HereNow()");
pubnub.GlobalHereNow<string>(globalHereNowShowUUID, globalHereNowIncludeUserState,DisplayReturnMessage, DisplayErrorMessage);
break;
case "29":
Console.WriteLine("ENTER UUID.");
string sessionUUID = Console.ReadLine();
pubnub.ChangeUUID(sessionUUID);
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("UUID = {0}",pubnub.SessionUUID);
Console.ResetColor();
break;
case "38":
示例5: IfGlobalHereNowIsCalledThenItShouldReturnInfoWithUserState
public void IfGlobalHereNowIsCalledThenItShouldReturnInfoWithUserState()
{
receivedGlobalHereNowMessage = false;
currentTestCase = "IfGlobalHereNowIsCalledThenItShouldReturnInfoWithUserState";
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = customUUID;
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfGlobalHereNowIsCalledThenItShouldReturnInfoWithUserState";
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);
globalHereNowManualEvent = new ManualResetEvent(false);
pubnub.GlobalHereNow<string>(true, true, ThenGlobalHereNowShouldReturnMessage, DummyErrorCallback);
globalHereNowManualEvent.WaitOne();
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(receivedGlobalHereNowMessage, "global_here_now message not received for user state");
}
示例6: IfGlobalHereNowIsCalledThenItShouldReturnInfo
public void IfGlobalHereNowIsCalledThenItShouldReturnInfo()
{
receivedGlobalHereNowMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfGlobalHereNowIsCalledThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : manualResetEventsWaitTimeout;
Thread.Sleep(1000);
globalHereNowManualEvent = new ManualResetEvent(false);
pubnub.GlobalHereNow<string>(true, true, ThenGlobalHereNowShouldReturnMessage, DummyErrorCallback);
globalHereNowManualEvent.WaitOne();
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.True(receivedGlobalHereNowMessage, "global_here_now message not received");
}
示例7: Main
//.........这里部分代码省略.........
//Console.WriteLine ("NOTE: Hopefully you added local user state.");
Console.WriteLine ("If you want to consider already created local user state, press ENTER");
Console.WriteLine ("Else enter user state in json format (Eg. {\"key1\":\"value1\",\"key2\":\"value2\"}");
string manualJsonUserState = Console.ReadLine ();
string jsonUserState = "";
if (string.IsNullOrEmpty (manualJsonUserState)) {
jsonUserState = pubnub.GetLocalUserState (setUserStateChannel);
} else {
jsonUserState = manualJsonUserState;
}
if (jsonUserState == "" || jsonUserState == "{}") {
Console.WriteLine ("Invalid User State");
break;
}
Console.WriteLine ("Enter UUID. (Optional. Press ENTER to skip it)");
string uuid = Console.ReadLine ();
if (string.IsNullOrEmpty (uuid)) {
pubnub.SetUserState<string> (setUserStateChannel, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
} else {
pubnub.SetUserState<string> (setUserStateChannel, uuid, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
}
break;
case "27":
Console.WriteLine ("Enter channel name");
string getUserStateChannel2 = Console.ReadLine ();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("Channel = {0}", getUserStateChannel2));
Console.ResetColor ();
Console.WriteLine ("Enter UUID. (Optional. Press ENTER to skip it)");
string uuid2 = Console.ReadLine ();
if (string.IsNullOrEmpty (uuid2)) {
pubnub.GetUserState<string> (getUserStateChannel2, DisplayReturnMessage, DisplayErrorMessage);
} else {
pubnub.GetUserState<string> (getUserStateChannel2, uuid2, DisplayReturnMessage, DisplayErrorMessage);
}
break;
case "28":
Console.WriteLine ("Enter uuid for WhereNow. To consider SessionUUID, just press ENTER");
string whereNowUuid = Console.ReadLine ();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("uuid = {0}", whereNowUuid));
Console.ResetColor ();
Console.WriteLine ();
Console.WriteLine ("Running Where_Now()");
pubnub.WhereNow<string> (whereNowUuid, DisplayReturnMessage, DisplayErrorMessage);
break;
case "29":
bool globalHereNowShowUUID = true;
bool globalHereNowIncludeUserState = false;
Console.WriteLine ("Show UUID List? Y or N? Default is Y. Press N for No Else press ENTER");
string userChoiceGlobalHereNowShowUUID = Console.ReadLine ();
if (userChoiceGlobalHereNowShowUUID.ToLower () == "n") {
globalHereNowShowUUID = false;
}
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("Show UUID = {0}", globalHereNowShowUUID));
Console.ResetColor ();
Console.WriteLine ();
Console.WriteLine ("Include User State? Y or N? Default is N. Press Y for Yes Else press ENTER");
string userChoiceGlobalHereNowIncludeUserState = Console.ReadLine ();
if (userChoiceGlobalHereNowIncludeUserState.ToLower () == "y") {
globalHereNowIncludeUserState = true;
}
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("Include User State = {0}", globalHereNowIncludeUserState));
Console.ResetColor ();
Console.WriteLine ();
Console.WriteLine ("Running Global HereNow()");
pubnub.GlobalHereNow<string> (globalHereNowShowUUID, globalHereNowIncludeUserState, DisplayReturnMessage, DisplayErrorMessage);
break;
case "30":
Console.WriteLine ("ENTER UUID.");
string sessionUUID = Console.ReadLine ();
pubnub.ChangeUUID (sessionUUID);
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine ("UUID = {0}", pubnub.SessionUUID);
Console.ResetColor ();
break;
default:
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine ("INVALID CHOICE. ENTER 99 FOR EXIT OR QUIT");
Console.ResetColor ();
break;
}
if (!exitFlag) {
userinput = Console.ReadLine ();
Int32.TryParse (userinput, out currentUserChoice);
}
}
Console.WriteLine ("\nPress any key to exit.\n\n");
Console.ReadLine ();
}