本文整理汇总了C#中Pubnub.SetLocalUserState方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.SetLocalUserState方法的具体用法?C# Pubnub.SetLocalUserState怎么用?C# Pubnub.SetLocalUserState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.SetLocalUserState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
break;
case "22":
Console.WriteLine ("Enter Presence Heartbeat Interval in seconds");
Console.WriteLine ("NOTE: We apply the logic Presence Heartbeat/2-1 seconds to calculate it." +
"\nIf you enter a value greater than the value from this logic, \nwe will reset it to this calculated value.");
string pnHeartbeatIntervalInput = Console.ReadLine ();
Int32.TryParse (pnHeartbeatIntervalInput, out presenceHeartbeatInterval);
pubnub.PresenceHeartbeatInterval = presenceHeartbeatInterval;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("Presence Heartbeat Interval = {0}", pubnub.PresenceHeartbeatInterval));
Console.ResetColor ();
break;
case "23":
Console.WriteLine ("Enter channel name");
string userStateChannel = Console.ReadLine ();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("Channel = {0}", userStateChannel));
Console.ResetColor ();
Console.WriteLine ("User State will be accepted as dictionary key:value pair. You will be asked to enter multiple keys, to exit add an empty key");
while (true) {
Console.WriteLine ("Enter key. ");
string keyUserState = Console.ReadLine ();
if (string.IsNullOrEmpty (keyUserState.Trim ())) {
Console.WriteLine ("dictionary key:value pair entry completed.");
break;
}
Console.WriteLine ("Enter value");
string valueUserState = Console.ReadLine ();
int valueInt;
double valueDouble;
string currentUserState = "";
if (Int32.TryParse (valueUserState, out valueInt)) {
currentUserState = pubnub.SetLocalUserState (userStateChannel, keyUserState, valueInt);
} else if (Double.TryParse (valueUserState, out valueDouble)) {
currentUserState = pubnub.SetLocalUserState (userStateChannel, keyUserState, valueDouble);
} else {
currentUserState = pubnub.SetLocalUserState (userStateChannel, keyUserState, valueUserState);
}
Console.ForegroundColor = ConsoleColor.Blue;
if (!string.IsNullOrEmpty (currentUserState)) {
Console.WriteLine ("Current User State = {0}", currentUserState);
} else {
Console.Write ("No User State Exists");
}
Console.ResetColor ();
}
break;
case "24":
Console.WriteLine ("Enter channel name");
string deleteUserStateChannel = Console.ReadLine ();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine (string.Format ("Channel = {0}", deleteUserStateChannel));
Console.ResetColor ();
Console.WriteLine ("Enter key of the local user state to be deleted");
string deleteKeyUserState = Console.ReadLine ();
string currentUserStateAfterDelete = pubnub.SetLocalUserState (deleteUserStateChannel, deleteKeyUserState, null);
Console.ForegroundColor = ConsoleColor.Blue;
if (!string.IsNullOrEmpty (currentUserStateAfterDelete)) {
Console.WriteLine ("Current User State = {0}", currentUserStateAfterDelete);
} else {
Console.Write ("No User State Exists");