Esempio n. 1
0
        void objXmpp_OnIq(object sender, IQ iq)
        {
            if (iq != null)
            {
                // No Iq with query
                if (iq.HasTag(typeof(agsXMPP.protocol.extensions.si.SI)))
                {
                    if (iq.Type == IqType.set)
                    {
                        agsXMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI;

                        agsXMPP.protocol.extensions.filetransfer.File file = si.File;
                        if (file != null)
                        {
                            // somebody wants to send a file to us
                            //frmFileTransfer frmFile = new frmFileTransfer(XmppCon, iq);
                            //frmFile.Show();
                            Console.WriteLine(file.Description);
                            FileTransfer FT = new FileTransfer(objXmpp, iq);
                        }
                    }
                }
                else
                {
                    Element query = iq.Query;

                    if (query != null)
                    {
                        if (query.GetType() == typeof(agsXMPP.protocol.iq.version.Version))
                        {
                            // its a version IQ VersionIQ
                            agsXMPP.protocol.iq.version.Version version = query as agsXMPP.protocol.iq.version.Version;
                            if (iq.Type == IqType.get)
                            {
                                // Somebody wants to know our client version, so send it back
                                iq.SwitchDirection();
                                iq.Type = IqType.result;

                                version.Name = "MiniClient";
                                version.Ver  = "0.5";
                                version.Os   = Environment.OSVersion.ToString();

                                objXmpp.Send(iq);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void OnIq(object sender, agsXMPP.protocol.client.IQ iq)
        {
            if (iq != null)
            {
                if (iq.Error != null)
                {
                    OnIqError(iq);
                }

                // No Iq with Query
                if (iq.HasTag(typeof(agsXMPP.protocol.extensions.si.SI)))
                {
                    if (iq.Type == IqType.set)
                    {
                        agsXMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI;

                        agsXMPP.protocol.extensions.filetransfer.File file = si.File;
                        if (file != null)
                        {
                            // somebody wants to send a file to us
                            Console.WriteLine(file.Size.ToString());
                            Console.WriteLine(file.Name);
                        }
                    }
                }
                else
                {
                    Element query = iq.Query;

                    if (query != null)
                    {
                        if (query.GetType() == typeof(agsXMPP.protocol.iq.version.Version))
                        {
                            OnIqVersion(iq, query);
                        }
                        else if (query.GetType() == typeof(agsXMPP.protocol.iq.register.Register))
                        {
                            OnIqRegister(iq, query);
                        }
                    }
                }
            }
        }