本文整理汇总了C#中Pubnub.History方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.History方法的具体用法?C# Pubnub.History怎么用?C# Pubnub.History使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.History方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: History
public void History()
{
var channel = "csharp_history_test";
var pn = new Pubnub("demo", "demo", string.Empty);
pn.Publish(channel, new { name = "test" });
Assert.IsTrue(pn.History("csharp_history_test", 10).Count > 0);
}
示例2: ThenItShouldReturnHistoryMessages
public void ThenItShouldReturnHistoryMessages()
{
Pubnub pubnub = new Pubnub(
"demo",
"demo",
"",
false
);
string channel = "my/channel";
List<object> history = pubnub.History(channel, 1);
Assert.AreEqual(1, history.Count);
}
示例3: 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;
}
);
}