private void MessageCallback(object sender, Message msg, object data) { if (base.InvokeRequired) { base.BeginInvoke(new MessageCB(this, (IntPtr) this.MessageCallback), new object[] { sender, msg, data }); } else if (msg.get_Type() == 2) { this.IncomingMessage(msg); } }
private void XmppCon_OnMessage(object sender, Message msg) { if (base.InvokeRequired) { base.BeginInvoke(new OnMessageDelegate(this.XmppCon_OnMessage), new object[] { sender, msg }); } else if ((msg.get_Type() != 2) && (msg.get_Type() != 0)) { Element element = msg.SelectSingleElement(typeof(Data)); if (element != null) { Data data = element as Data; if (data.get_Type() == 0) { frmXData data2 = new frmXData(data); data2.Text = "xData Form from " + msg.get_From().ToString(); data2.Show(); } } else if (!Util.ChatForms.ContainsKey(msg.get_From().get_Bare())) { RosterNode rosterItem = this.rosterControl.GetRosterItem(msg.get_From()); string nickname = msg.get_From().get_Bare(); if (rosterItem != null) { nickname = rosterItem.Text; } frmChat chat = new frmChat(msg.get_From(), this.XmppCon, nickname); chat.CreateControl(); chat.Show(); chat.IncomingMessage(msg); } } }
private void IncomingMessage(Message msg) { if (msg.get_Type() != 0) { if (msg.get_Subject() != null) { this.txtSubject.Text = msg.get_Subject(); this.rtfChat.SelectionColor = Color.DarkGreen; this.rtfChat.AppendText(msg.get_From().get_Resource() + " changed subject: "); this.rtfChat.SelectionColor = Color.Black; this.rtfChat.AppendText(msg.get_Subject()); this.rtfChat.AppendText("\r\n"); } else if (msg.get_Body() != null) { this.rtfChat.SelectionColor = Color.Red; this.rtfChat.AppendText(msg.get_From().get_Resource() + " said: "); this.rtfChat.SelectionColor = Color.Black; this.rtfChat.AppendText(msg.get_Body()); this.rtfChat.AppendText("\r\n"); } } }