本文整理汇总了C#中Pubnub.GetUserState方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.GetUserState方法的具体用法?C# Pubnub.GetUserState怎么用?C# Pubnub.GetUserState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.GetUserState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
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, setUserStateChannelGroup, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
}
else
{
pubnub.SetUserState<string>(setUserStateChannel, setUserStateChannelGroup, uuid, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
}
break;
case "26":
Console.WriteLine("Enter channel name");
Console.WriteLine("NOTE: If you want to consider only Channel Group, just hit ENTER");
string getUserStateChannel2 = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("Channel = {0}", getUserStateChannel2));
Console.ResetColor();
Console.WriteLine("Enter channel group name");
Console.WriteLine("NOTE: If you want to consider only Channel, just hit ENTER");
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();
示例2: IfSetAndGetUserStateThenItShouldReturnInfo
public void IfSetAndGetUserStateThenItShouldReturnInfo()
{
receivedUserStateMessage = false;
currentTestCase = "IfSetAndGetUserStateThenItShouldReturnInfo";
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = customUUID;
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfSetAndGetUserStateThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
string channel = "hello_my_channel";
jsonUserState = "{\"testkey\":\"testval\"}";
userStateManualEvent = new ManualResetEvent(false);
pubnub.SetUserState<string>(channel,"", customUUID, jsonUserState, SetUserStateDummyMethodCallback, DummyErrorCallback);
userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);
if (receivedUserStateMessage)
{
Thread.Sleep(2000);
receivedUserStateMessage = false;
userStateManualEvent = new ManualResetEvent(false);
pubnub.GetUserState<string>(channel, "", customUUID, GetUserStateRegularCallback, DummyErrorCallback);
userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);
}
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedUserStateMessage, "IfSetAndGetUserStateThenItShouldReturnInfo failed");
}
示例3: IfSetAndDeleteUserStateThenItShouldReturnInfo
public void IfSetAndDeleteUserStateThenItShouldReturnInfo()
{
receivedUserStateMessage = false;
currentTestCase = "IfSetAndDeleteUserStateThenItShouldReturnInfo";
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = customUUID;
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "IfSetAndDeleteUserStateThenItShouldReturnInfo";
pubnub.PubnubUnitTest = unitTest;
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
string channel = "hello_my_channel";
jsonUserState = "{\"k\":\"v\"}";
KeyValuePair<string, object> kvp = new KeyValuePair<string, object>("k", "v");
userStateManualEvent = new ManualResetEvent(false);
pubnub.SetUserState<string>(channel, kvp, SetUserStateDummyMethodCallback, DummyErrorCallback);
userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);
Thread.Sleep(2000);
receivedUserStateMessage = false;
KeyValuePair<string, object> kvp2 = new KeyValuePair<string, object>("k2", "v2");
userStateManualEvent = new ManualResetEvent(false);
pubnub.SetUserState<string>(channel, kvp2, SetUserStateDummyMethodCallback, DummyErrorCallback);
userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);
Thread.Sleep(2000);
receivedUserStateMessage = false;
userStateManualEvent = new ManualResetEvent(false);
pubnub.GetUserState<string>(channel, "", GetUserStateRegularCallback, DummyErrorCallback);
userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);
Thread.Sleep(2000);
receivedUserStateMessage = false;
KeyValuePair<string, object> kvp22 = new KeyValuePair<string, object>("k2", null);
userStateManualEvent = new ManualResetEvent(false);
pubnub.SetUserState<string>(channel, kvp22, SetUserStateDummyMethodCallback, DummyErrorCallback);
userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);
Thread.Sleep(2000);
receivedUserStateMessage = false;
userStateManualEvent = new ManualResetEvent(false);
pubnub.GetUserState<string>(channel, "", GetUserStateRegularCallback, DummyErrorCallback);
userStateManualEvent.WaitOne(manualResetEventsWaitTimeout);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedUserStateMessage, "IfSetAndDeleteUserStateThenItShouldReturnInfo message not received");
}
示例4: 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 ();