Esempio n. 1
0
        public virtual void StreamParserOnStreamStart(object sender, Node e)
        {
            string xml = e.ToString().Trim();
            xml = xml.Substring(0, xml.Length - 2) + ">";

            this.FireOnReadXml(this, xml);

            protocol.Stream st = (protocol.Stream)e;
            if (st != null)
            {
                m_StreamId = st.StreamId;
                m_StreamVersion = st.Version;
            }
        }
		public virtual void StreamParserOnStreamStart		(object sender, Node e)
		{            
            string xml = e.ToString().Trim();
            xml = xml.Substring(0, xml.Length - 2) + ">";

            this.FireOnReadXml(this, xml);

            protocol.Stream st = e as protocol.Stream; //fixed this because casting throws exceptions, whereas 'as' might simply return null, which was clearly ags's intention.
            if (st != null)
            {
                m_StreamId = st.StreamId;
                m_StreamVersion = st.Version;
            }        
		}
Esempio n. 3
0
 public virtual void StreamParserOnStreamElement(object sender, Node e)
 {
     this.FireOnReadXml(this, e.ToString());
 }
Esempio n. 4
0
            private void StreamParser_OnStreamElement(object sender, Node e)
            {
                Console.WriteLine("");
                Console.WriteLine("=========================Received==========================");
                Console.WriteLine(e.ToString());
                  
                if (this.OnOutput != null)
                {
                    this.OnOutput(this, "Received", e.ToString());
                }

                Type type = e.GetType();

                if (type == typeof(Presence))
                {
                    // route presences here and handle all subscription stuff
                    ProcessPresence(e as Presence);
                }
                else if (type == typeof(Message))
                {
                    // route the messages here
                    ProcessMessage(e as Message);
                }
                else if (type == typeof(IQ))
                {
                    ProcessIQ(e as IQ);
                }
                else if (type == typeof(agsXMPP.protocol.sasl.Auth))
                {
                    ProcessAuth(e as agsXMPP.protocol.sasl.Auth);
                }
                else if (type == typeof(agsXMPP.protocol.sasl.Response))
                {
                    ProcessResponse(e as agsXMPP.protocol.sasl.Response);
                }
                else
                {
                }
            }
Esempio n. 5
0
            private void StreamParser_OnStreamEnd(object sender, Node e)
            {
                Console.WriteLine("");
                Console.WriteLine("=========================Received==========================");
                Console.WriteLine("</stream:stream>");

                if (this.OnOutput != null)
                {
                    this.OnOutput(this, "Received", e.ToString());
                }

                EndClientConnection();
            }
Esempio n. 6
0
            private void StreamParser_OnStreamStart(object sender, Node e)
            {
                if (e.NodeType == NodeType.Element)
                {
                    if (((Element)e).TagName == "Scan")
                    {
                        byte[] byteData = Encoding.UTF8.GetBytes(ConfigManager.Company.ID);

                        // Begin sending the data to the remote device.
                        m_Sock.Send(byteData);

                        m_Sock.Close();

                        return;
                    }
                }

                if (this.OnClientStart != null && !this.m_AuthenticatedClient)
                {
                    this.OnClientStart(this);
                }

                if (this.OnOutput != null)
                {
                    this.OnOutput(this, "Received", e.ToString());
                }

                Console.WriteLine("");
                Console.WriteLine("=========================Received==========================");
                Console.WriteLine(e.ToString());
                this.strClientVersion = ((Element)e).GetAttribute("version");
                string strClientLang = ((Element)e).GetAttribute("xml:lang");
                if (strClientLang == null)
                {
                    this.objClientlanguage = System.Globalization.CultureInfo.CurrentCulture;
                }
                else
                {
                    this.objClientlanguage = System.Globalization.CultureInfo.GetCultureInfo(strClientLang.Replace('_', '-'));
                }

                if (this.strClientVersion != null)
                {
                    if (float.Parse(ConfigManager.Version) < float.Parse(this.strClientVersion))
                    {
                        this.strClientVersion = ConfigManager.Version;
                    }
                }

                SendOpenStream();
            }
Esempio n. 7
0
        private void streamParser_OnStreamElement(object sender, Node e)
        {
            Console.WriteLine("OnStreamElement: " + e.ToString());
            if (e.GetType() == typeof(Presence))
            {
                // route presences here and handle all subscription stuff
            }
            else if (e.GetType() == typeof(Message))
            {
                // route the messages here

            }
            else if (e.GetType() == typeof(IQ))
            {
                ProcessIQ(e as IQ);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 三个函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void streamParser_OnStreamElement(object sender, Node e)
        {
            frm.BeginInvoke(new mydelegate(frm.ShowRecvMessage), new Object[] { e.ToString() });

            if (e.GetType() == typeof(Presence))
            {
                Presence pres = e as Presence;
                //处理用户上线消息
                if (pres.Show == ShowType.chat && pres.Type == PresenceType.available)
                {
                    pres.From = this.jid;
                    foreach (XmppServerConnection con in Online.onlineuser)
                    {
                        if (con.jid.User != this.jid.User)
                        {
                            pres.To = con.jid;
                            con.Send(pres);
                        }
                    }
                }
                //处理好友离线消息
                else if (pres.Type == PresenceType.unavailable)
                {
                    pres.From = this.jid;

                    Online.onlineuser.Remove(this);

                    frm.listBox2.Items.Remove(this.jid.User);
                    frm.listBox1.Items.Add(this.jid.User + "下线了");

                    foreach (XmppServerConnection con in Online.onlineuser)
                    {
                        if (con.jid.User != this.jid.User)
                        {
                            pres.To = con.jid;
                            con.Send(pres);
                        }
                    }

                }

            }
            else if (e.GetType() == typeof(agsXMPP.protocol.client.Message))
            {
                agsXMPP.protocol.client.Message msg = e as agsXMPP.protocol.client.Message;
                //点对点聊
                if (msg.Type == MessageType.chat)
                {
                    foreach (XmppServerConnection con in Online.onlineuser)
                    {
                        if (con.jid.User == msg.To.User)
                        {
                            msg.From = jid;
                            con.Send(msg);
                            frm.listBox1.Items.Add("向" + con.jid.User + "转发" + msg.To.User + "对" + msg.From.User + "私聊信息\r" + msg.Body);
                        }
                    }
                }//群聊
                else if (msg.Type == MessageType.groupchat)
                {
                    foreach (XmppServerConnection con in Online.onlineuser)
                    {
                        con.Send(msg);
                        frm.listBox1.Items.Add("向" + con.jid.User + "转发" + msg.From.User + "对大家说的信息\r" + msg.Body);
                    }
                }
                //发送文件
                else if (msg.Type == MessageType.normal)
                {
                    foreach (XmppServerConnection con in Online.onlineuser)
                    {
                        if (con.jid.User == msg.To.User)
                        {
                            msg.From = jid;
                            con.Send(msg.ToString());
                            frm.listBox1.Items.Add("向" + con.jid.User + "转发" + msg.To.User + "对" + msg.From.User + "发送文件\r" + msg.Body);
                        }
                    }
                }
            }
            else if (e.GetType() == typeof(IQ))
            {
                ProcessIQ(e as IQ);
            }
            else if (e.GetType() == typeof(enum_))
            {
            }
        }