public ChatHandler(Account account, bool isMucUser, JID jid) : base(account) { m_Jid = jid; m_IsMucUser = isMucUser; base.Account.ConnectionStateChanged += HandleConnectionStateChanged; base.Ready = (base.Account.ConnectionState == AccountConnectionState.Connected); base.AppendStatus(String.Format("Conversation with {0}.", jid.ToString())); }
[Test] public void Test_Create() { JID j = new JID("foo", "jabber.com", "there"); Assert.AreEqual("[email protected]/there", j.ToString()); j = new JID(null, "jabber.com", null); Assert.AreEqual("jabber.com", j.ToString()); j = new JID("foo", "jabber.com", null); Assert.AreEqual("*****@*****.**", j.ToString()); j = new JID(null, "jabber.com", "there"); Assert.AreEqual("jabber.com/there", j.ToString()); }
private void m_pres_OnPrimarySessionChange(object sender, JID bare) { Presence pres = m_pres[bare]; LinkedList nodelist = (LinkedList) m_items[bare.ToString()]; if (nodelist == null) return; foreach (ItemNode n in nodelist) { n.ChangePresence(pres); } }
private Message ReceiveMessage(JID inJId, NUnit.Framework.Constraints.Constraint inMatcher) { Message result; Assert.That(mQueue.TryPoll(TimeSpan.FromSeconds(5), out result), Is.True, "5秒間に何らかのメッセージが送られてこなければならない"); Assert.That(result, Is.Not.Null); Assert.That(result.Body, inMatcher); Assert.That(result.From.ToString(), Is.EqualTo(inJId.ToString())); return result; }
public void OpenChatWindow(JID jid, bool isMucUser, bool focus, ChatHandlerEvent callback) { QApplication.Invoke(delegate { IChatHandler handler = null; string windowJid = isMucUser ? jid.ToString() : jid.Bare; lock (m_ChatWindows) { if (!m_ChatWindows.ContainsKey(windowJid)) { handler = new ChatHandler(m_Account, isMucUser, windowJid); var window = new ChatWindow(handler); window.Closed += HandleChatWindowClosed; m_ChatWindows.Add(windowJid, window); Gui.TabbedChatsWindow.AddChatWindow(window, focus); } else { var window = m_ChatWindows[windowJid]; if (focus) { Gui.TabbedChatsWindow.FocusChatWindow(window); } handler = (ChatHandler)window.Handler; } } if (callback != null) { callback(handler); } }); }
/// <summary>Is the peer online to the best of our knowledge.</summary> public bool IsUserOnline(JID jid) { if(!_online.ContainsKey(jid.ToString())) { return jid.Equals(_jc.JID); } return true; }
/// <summary>Send a Query to a remote peer.</summary> public bool SendTo(Element msg, JID to) { if(!_online.ContainsKey(to.ToString())) { return false; } SendByIQ(msg, to); return true; }
void ReceivedMood(JID from, string node, PubSubItem item) { Mood mood = (Mood)item["mood"]; m_FriendMoods[from.Bare] = mood; // Only show in feed if we know this is a recent event. if (mood["timestamp"] != null && DateTime.Now.Subtract(DateTime.Parse(mood["timestamp"].InnerText)).TotalSeconds <= 60) { m_Account.PostActivityFeedItem(from.ToString(), "mood", mood.MoodName, mood.Text); } }