Exemple #1
0
 private void chatToolStripMenuItem_Click(object sender, EventArgs e)
 {
     RosterNode node = rosterControl.SelectedItem();
     if (node != null)
     {
         if (!Util.ChatForms.ContainsKey(node.RosterItem.Jid.ToString()))
         {
             frmChat f = new frmChat(node.RosterItem.Jid, XmppCon, node.Text);
             f.Show();
         }
     }
 }
Exemple #2
0
 private void rosterStartChat_mouseDoubleClick(object sender, EventArgs e)
 {
     RosterNode node = rosterControl.SelectedItem();
     if (node.NodeType == RosterNodeType.RosterNode && node != null)
     {
         if (!Util.ChatForms.ContainsKey(node.RosterItem.Jid.ToString()))
         {
             frmChat f = new frmChat(node.RosterItem.Jid, XmppCon, node.Text);
             f.Show();
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// We received a message
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="msg"></param>
        private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new OnMessageDelegate(XmppCon_OnMessage), new object[] { sender, msg });
                return;
            }

            // Dont handle GroupChat Messages here, they have their own callbacks in the
            // GroupChat Form
            if (msg.Type == MessageType.groupchat)
                return;

            if (msg.Type == MessageType.error)
            {
                //Handle errors here
                // we dont handle them in this example
                return;
            }

            // check for xData Message

            if (msg.HasTag(typeof(Data)))
            {
                Element e = msg.SelectSingleElement(typeof(Data));
                Data xdata = e as Data;
                if (xdata.Type == XDataFormType.form)
                {
                    frmXData fXData = new frmXData(xdata);
                    fXData.Text = "xData Form from " + msg.From.ToString();
                    fXData.Show();
                }
            }
            else if (msg.HasTag(typeof(agsXMPP.protocol.extensions.ibb.Data)))
            {
                // ignore IBB messages
                return;
            }
            else
            {
                if (msg.Body != null)
                {
                    if (!Util.ChatForms.ContainsKey(msg.From.Bare))
                    {
                        RosterNode rn = rosterControl.GetRosterItem(msg.From);
                        string nick = msg.From.Bare;
                        if (rn != null)
                            nick = rn.Text;

                        frmChat f = new frmChat(msg.From, XmppCon, nick);
                        f.Show();
                        f.IncomingMessage(msg);
                    }
                }
            }
        }