本文整理汇总了C#中Pubnub.Time方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.Time方法的具体用法?C# Pubnub.Time怎么用?C# Pubnub.Time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.Time方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThenWithProxyItShouldReturnTimeStamp
public void ThenWithProxyItShouldReturnTimeStamp()
{
bool proxyConfigured = false;
PubnubProxy proxy = new PubnubProxy();
proxy.ProxyServer = "test.pandu.com";
proxy.ProxyPort = 808;
proxy.ProxyUserName = "tuvpnfreeproxy";
proxy.ProxyPassword = "Rx8zW78k";
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenWithProxyItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
if (proxyConfigured)
{
pubnub.Proxy = proxy;
pubnub.Time<string>(ReturnProxyPresenceTimeStampCallback, DummyErrorCallback);
mreProxy.WaitOne(310 * 1000);
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(timeReceivedWhenProxy, "time() Failed");
}
else
{
Assert.Ignore("Proxy setup not configured. After setup Set proxyConfigured to true");
}
}
示例2: ThenWithProxyItShouldReturnTimeStamp
public void ThenWithProxyItShouldReturnTimeStamp()
{
bool proxyConfigured = false;
PubnubProxy proxy = new PubnubProxy();
proxy.ProxyServer = "test.pandu.com";
proxy.ProxyPort = 808;
proxy.ProxyUserName = "tuvpnfreeproxy";
proxy.ProxyPassword = "Rx8zW78k";
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenWithProxyItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
if (proxyConfigured)
{
pubnub.Proxy = proxy;
pubnub.Time<string>(ReturnProxyPresenceTimeStampCallback, DummyErrorCallback);
mreProxy.WaitOne(310 * 1000, true);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.True(timeReceivedWhenProxy, "time() Failed");
}
else
{
Assert.That(!proxyConfigured);
}
}
示例3: ThenItShouldReturnTimeStampSSL
public void ThenItShouldReturnTimeStampSSL ()
{
Pubnub pubnub = new Pubnub (
Common.PublishKey,
Common.SubscribeKey,
"",
"",
true
);
Common common = new Common ();
common.DeliveryStatus = false;
common.Response = null;
pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");
;
string response = "";
pubnub.Time (common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
common.WaitForResponse ();
IList<object> fields = common.Response as IList<object>;
response = fields [0].ToString ();
Console.WriteLine ("Response:" + response);
Assert.AreNotEqual ("0", response);
pubnub.EndPendingRequests ();
}
示例4: ThenItShouldReturnTimeStamp
public void ThenItShouldReturnTimeStamp()
{
Pubnub pubnub = new Pubnub(
"demo",
"demo",
"",
"",
false
);
Common common = new Common();
common.DeliveryStatus = false;
common.Response = null;
pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");;
string response = "";
pubnub.Time(common.DisplayReturnMessage);
while (!common.DeliveryStatus) ;
IList<object> fields = common.Response as IList<object>;
response = fields[0].ToString();
Console.WriteLine("Response:" + response);
Assert.AreNotEqual("0",response);
}
示例5: Timestamp
public long Timestamp(Pubnub pubnub)
{
DeliveryStatus = false;
pubnub.Time(DisplayReturnMessage);
while (!DeliveryStatus) ;
IList<object> fields = Response as IList<object>;
return Convert.ToInt64(fields[0].ToString());
}
示例6: ThenItShouldReturnTimeStamp
public void ThenItShouldReturnTimeStamp()
{
Pubnub pubnub = new Pubnub(
"demo",
"demo",
"",
false
);
object timestamp = pubnub.Time();
Assert.AreNotEqual(null, timestamp);
}
示例7: ThenItShouldReturnTimeStamp
public void ThenItShouldReturnTimeStamp()
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
EnqueueCallback(() => pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback));
EnqueueConditional(() => isTimeStamp);
EnqueueCallback(() => Assert.IsTrue(timeReceived, "time() Failed"));
EnqueueTestComplete();
}
示例8: ThenItShouldReturnTimeStamp
public void ThenItShouldReturnTimeStamp()
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback);
mreTime.WaitOne(310 * 1000);
Assert.IsTrue(timeReceived, "time() Failed");
}
示例9: ThenItShouldReturnTimeStamp
public void ThenItShouldReturnTimeStamp()
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
pubnub.Time<string>(ReturnTimeStampCallback);
mreTime.WaitOne(310 * 1000);
UUnitAssert.True(timeReceived, "time() Failed");
}
示例10: ThenItShouldReturnTimeStamp
public void ThenItShouldReturnTimeStamp()
{
mreTime = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
EnqueueCallback(() => pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback));
mreTime.WaitOne(310 * 1000);
EnqueueCallback(() => Assert.IsTrue(timeReceived, "time() Failed"));
EnqueueTestComplete();
});
}
示例11: Main
static void Main(string[] args)
{
var myIp = GetExternalIp();
// Start the HTML5 Pubnub client
Process.Start(@"..\..\..\PubNub-HTML5-Client.html");
System.Threading.Thread.Sleep(2000);
Pubnub pubnub = new Pubnub(
"pub-c-4331b990-8629-4f47-9669-51f0e2ee9c9d", // PUBLISH_KEY
"sub-c-bfd2fbba-0428-11e3-91de-02ee2ddab7fe", // SUBSCRIBE_KEY
"sec-c-NDExYTBlYjUtM2QyYS00YTJiLWExNDItM2Y5NDQ2ZjA1N2Uy", // SECRET_KEY
"", // CIPHER_KEY
true // SSL_ON?
);
string channel = "ninja-channel";
// Publish a sample message to Pubnub
pubnub.Publish<string>(channel, "", DisplayReturnMessage);
// Show PubNub server time
pubnub.Time<string>(DisplayReturnMessage);
//Console.WriteLine("Server Time: " + serverTime.ToString());
// Subscribe for receiving messages (in a background task to avoid blocking)
System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
() =>
pubnub.Subscribe<string>(
channel,
DisplayReturnMessage,
DisplayConnectStatusMessage
)
);
t.Start();
// Read messages from the console and publish them to Pubnub
while (true)
{
Console.Write("Enter a message to be sent to Pubnub: ");
string msg = Console.ReadLine();
pubnub.Publish<string>(channel, myIp + " : " + msg, DisplayReturnMessage);
Console.WriteLine("Message {0} sent.", msg);
}
}
示例12: ThenItShouldReturnTimeStamp
public void ThenItShouldReturnTimeStamp()
{
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
pubnub.Time<string>(ReturnTimeStampCallback, DummyErrorCallback);
mreTime.WaitOne(60 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(timeReceived, "time() Failed");
TestComplete();
});
});
}
示例13: ThenWithProxyItShouldReturnTimeStamp
public void ThenWithProxyItShouldReturnTimeStamp()
{
PubnubProxy proxy = new PubnubProxy();
proxy.ProxyServer = "test.pandu.com";
proxy.ProxyPort = 808;
proxy.ProxyUserName = "tuvpnfreeproxy";
proxy.ProxyPassword = "Rx8zW78k";
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
pubnub.Proxy = proxy;
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGetRequestServerTime";
unitTest.TestCaseName = "ThenWithProxyItShouldReturnTimeStamp";
pubnub.PubnubUnitTest = unitTest;
pubnub.Time<string>(ReturnProxyPresenceTimeStampCallback);
mreProxy.WaitOne(310 * 1000);
Assert.IsTrue(timeReceivedWhenProxy, "time() Failed");
}
示例14: Main
public static void Main()
{
// -----------------
// Init Pubnub Class
// -----------------
Pubnub pubnub = new Pubnub(
"demo", // PUBLISH_KEY
"demo", // SUBSCRIBE_KEY
"", // SECRET_KEY
false // SSL_ON?
);
string channel = "test-channel-顶";
// ---------------
// Publish Message
// ---------------
List<object> info = pubnub.Publish( channel, "Hello World" );
// ----------------
// Publish Response
// ----------------
Console.WriteLine(
"Publish Success: " + info[0].ToString() +
"\nPublish Info: " + info[1]
);
// -------
// History
// -------
List<object> history = pubnub.History( channel, 1 );
foreach (object history_message in history) {
Console.Write("History Message: ");
Console.WriteLine(history_message);
}
// ----------------------
// Get PubNub Server Time
// ----------------------
object timestamp = pubnub.Time();
Console.WriteLine("Server Time: " + timestamp.ToString());
// ---------
// Subscribe
// ---------
pubnub.Subscribe(
channel,
delegate (object message) {
Console.WriteLine("Received Message -> '" + message + "'");
return true;
}
);
}
示例15: Main
//.........这里部分代码省略.........
if (enableCustomUUID.Trim().ToLower() == "y")
{
Console.WriteLine("ENTER Session UUID.");
string sessionUUID = Console.ReadLine();
pubnub.SessionUUID = sessionUUID;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Accepted Custom Session UUID.");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Default Session UUID opted.");
Console.ResetColor();
}
Console.WriteLine();
Console.WriteLine("By default Resume On Reconnect is enabled. Do you want to disable it? ENTER Y for Yes, else N");
string disableResumeOnReconnect = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
if (disableResumeOnReconnect.Trim().ToLower() == "y")
{
Console.WriteLine("Resume On Reconnect Disabled");
pubnub.EnableResumeOnReconnect = false;
}
else
{
Console.WriteLine("Resume On Reconnect Enabled by default");
pubnub.EnableResumeOnReconnect = true;
}
Console.ResetColor();
Console.WriteLine();
Console.WriteLine("Subscribe Timeout = 310 seconds (default). Enter the value to change, else press ENTER");
string subscribeTimeoutEntry = Console.ReadLine();
int subscribeTimeout;
Int32.TryParse(subscribeTimeoutEntry, out subscribeTimeout);
Console.ForegroundColor = ConsoleColor.Blue;
if (subscribeTimeout > 0)
{
Console.WriteLine("Subscribe Timeout = {0}",subscribeTimeout);
pubnub.SubscribeTimeout = subscribeTimeout;
}
else
{
Console.WriteLine("Subscribe Timeout = {0} (default)", pubnub.SubscribeTimeout);
}
Console.ResetColor();
Console.WriteLine();
Console.WriteLine("Non Subscribe Timeout = 15 seconds (default). Enter the value to change, else press ENTER");
string nonSubscribeTimeoutEntry = Console.ReadLine();
int nonSubscribeTimeout;
Int32.TryParse(nonSubscribeTimeoutEntry, out nonSubscribeTimeout);
Console.ForegroundColor = ConsoleColor.Blue;
if (nonSubscribeTimeout > 0)
{
Console.WriteLine("Non Subscribe Timeout = {0}", nonSubscribeTimeout);
pubnub.NonSubscribeTimeout = nonSubscribeTimeout;
}
else
{
Console.WriteLine("Non Subscribe Timeout = {0} (default)", pubnub.NonSubscribeTimeout);
}
Console.ResetColor();
Console.WriteLine();