本文整理汇总了C#中Presence.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Presence.ToString方法的具体用法?C# Presence.ToString怎么用?C# Presence.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Presence
的用法示例。
在下文中一共展示了Presence.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Create
public void Test_Create()
{
Presence p = new Presence(doc);
p.Type = PresenceType.available;
p.Status = "foo";
Assert.AreEqual("<presence><status>foo</status></presence>", p.ToString());
}
示例2: PresenceSet
/// <summary>
/// Sets the user's presence.
/// </summary>
/// <param name="presence">The presence to set.</param>
/// <param name="callback">The callback delegate to invoke on the server response.</param>
public void PresenceSet(Presence presence, Action<JObject> callback)
{
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "TurntableBot Public PresenceSet. Thread ID: {0}. Status: {1}.", Thread.CurrentThread.ManagedThreadId, presence.ToString().ToLower()));
JObject json = new JObject(
new JProperty("api", "presence.set"),
new JProperty("status", presence.ToString().ToLower()));
this.Send(json, callback);
}
示例3: PutPresence
public void PutPresence(Presence presence)
{
var db = GetDatabase();
var collection = db.GetCollection("offline_presence");
collection.Insert(
new BsonDocument(
new BsonElement("from", JIDEscaping.Unescape(presence.From.User)),
new BsonElement("to", JIDEscaping.Unescape(presence.To.User)),
new BsonElement("type", presence.Type.ToString()),
new BsonElement("value", presence.ToString())
));
}
示例4: HandlePresence
/// <summary>Received a presence message, type=unavailable means the user
/// has gone offline, everything else means the user is online.</summary>
protected void HandlePresence(object sender, Presence pres)
{
ProtocolLog.WriteIf(XmppLog, "Incoming: " + pres.ToString());
JID jid = pres.From;
if(jid == null || jid.Resource == null) {
return;
}
string key = jid.ToString();
if(jid.Resource.StartsWith(RESOURCE_NS)) {
if(pres.Type == PresenceType.unavailable) {
lock(_online) {
_online.Remove(key);
}
} else if(!_online.ContainsKey(key)) {
lock(_online) {
_online[jid.ToString()] = jid;
}
}
}
}