当前位置: 首页>>代码示例>>C#>>正文


C# IQ.SwitchDirection方法代码示例

本文整理汇总了C#中agsXMPP.protocol.client.IQ.SwitchDirection方法的典型用法代码示例。如果您正苦于以下问题:C# IQ.SwitchDirection方法的具体用法?C# IQ.SwitchDirection怎么用?C# IQ.SwitchDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在agsXMPP.protocol.client.IQ的用法示例。


在下文中一共展示了IQ.SwitchDirection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: xmppOnIq

        private void xmppOnIq(object sender, IQ iq)
        {
            if (iq.Type == IqType.get)
            {
                if (iq.Query != null)
                {
                    if (iq.Query is DiscoInfo)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        DiscoInfo di = getDiscoInfo();
                        iq.Query = di;
                        Jabber.xmpp.Send(iq);
                    }
                    else if (iq.Query is DiscoItems)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.error;
                        iq.Error = new Error(ErrorType.cancel, ErrorCondition.FeatureNotImplemented);
                        Jabber.xmpp.Send(iq);
                    }
                    else if (iq.Query is agsXMPP.protocol.iq.version.Version)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        agsXMPP.protocol.iq.version.Version version = iq.Query as agsXMPP.protocol.iq.version.Version;
                        version.Name = Assembly.GetExecutingAssembly().GetName().Name;
                        version.Ver = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                        version.Os = Environment.OSVersion.ToString();
                        Jabber.xmpp.Send(iq);
                    }
                    else if (iq.Query is agsXMPP.protocol.iq.last.Last)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        agsXMPP.protocol.iq.last.Last last = iq.Query as agsXMPP.protocol.iq.last.Last;
                        last.Seconds = new TimeSpan(Jabber._presence.getLastActivityTicks()).Seconds;
                        Jabber.xmpp.Send(iq);
                    }
                    else if (iq.Query is agsXMPP.protocol.iq.time.Time)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        agsXMPP.protocol.iq.time.Time time = iq.Query as agsXMPP.protocol.iq.time.Time;
                        time.Display = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
                        time.Tz = TimeZone.CurrentTimeZone.StandardName;
                        time.Utc = agsXMPP.util.Time.ISO_8601Date(DateTime.Now);
                        Jabber.xmpp.Send(iq);
                    }
                    else if (iq.Query is agsXMPP.protocol.extensions.ping.Ping)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        agsXMPP.protocol.extensions.ping.Ping ping = iq.Query as agsXMPP.protocol.extensions.ping.Ping;
                        Jabber.xmpp.Send(iq);
                    }
                    else if (iq.Query is agsXMPP.protocol.iq.avatar.Avatar)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        agsXMPP.protocol.iq.avatar.Avatar avatar = iq.Query as agsXMPP.protocol.iq.avatar.Avatar;
                        avatar.Data = null;
                        if (Jabber._identity.photo != null && Jabber._identity.photoFormat != null)
                        {
                            MemoryStream ms = new MemoryStream();
                            Jabber._identity.photo.Save(ms, Jabber._identity.photoFormat);
                            avatar.Data = ms.ToArray();
                            avatar.MimeType = "image/" + Jabber._identity.photoFormat.ToString();
                            ms.Close();
                            ms.Dispose();
                        }
                        Jabber.xmpp.Send(iq);
                    }
                    else if (iq.Query is agsXMPP.protocol.iq.vcard.Vcard)
                    {
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        iq.Query = Jabber._identity.toVcard();
                        Jabber.xmpp.Send(iq);
                    }









                }
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:92,代码来源:Query.cs

示例2: dbcon_oniq

        //------id maker------
        //         private void dbcon_OnRosterEnd(object sender)
        //       {
        //           if (InvokeRequired)
        //           {
        //              BeginInvoke(new ObjectHandler(dbcon_OnRosterEnd), new object[] { sender });
        //                 return;
        //           }
        //           dbcon.SendMyPresence();
        //       }
        //     private void dbcon_OnRosterStart(object sender)
        //     {
        //      if (InvokeRequired)
        //   {
        //        BeginInvoke(new ObjectHandler(dbcon_OnRosterStart), new object[] { sender });
        //         return;
        //     }
        // }
        //      private void dbcon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
        //   {
        //    if (InvokeRequired)
        // {
        //  BeginInvoke(new XmppClientConnection.RosterHandler(dbcon_OnRosterItem), new object[] { sender, item });
        // return;
        //    }
        //listBox1.Items.Add(String.Format("{0}", item.Jid.User));
        //listBox1.SelectedIndex = listBox1.Items.Count - 1;
        // _roster.AddRosterItem(item);
        //  }
        private void dbcon_oniq(object sender, IQ iq)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new IqHandler(dbcon_oniq), new object[] { sender, iq });
                return;
            }

            if (iq.Query != null)
            {
                if (iq.Query.GetType() == typeof(agsXMPP.protocol.iq.version.Version))
                {
                    agsXMPP.protocol.iq.version.Version vers = (agsXMPP.protocol.iq.version.Version)iq.Query;
                    if (iq.Type == agsXMPP.protocol.client.IqType.get)
                    {
                        iq.SwitchDirection();
                        iq.Type = agsXMPP.protocol.client.IqType.result;
                        vers.Name = "XMPPClient by [email protected]";
                        vers.Ver = "1.0.0";
                        vers.Os = "Coded By [email protected]\nFor More Visit: http://dbh4ck.blogspot.in";
                        ((XmppClientConnection)sender).Send(iq);
                    }
                }
            }
        }
开发者ID:dbh4ck,项目名称:XMPP-Client-csharp-Nimbuzz-Demo,代码行数:54,代码来源:formnimbuzz.cs

示例3: con_OnIq

        private void con_OnIq(object sender, IQ iq)
        {
            if (iq.Query != null)
            {
                if (iq.Query is DiscoInfo && iq.Type == IqType.get)
                {
                    /*
                    <iq type='get'
                        from='[email protected]/orchard'
                        to='plays.shakespeare.lit'
                        id='info1'>
                      <query xmlns='http://jabber.org/protocol/disco#info'/>
                    </iq>
                    */
                    iq.SwitchDirection();
                    iq.Type = IqType.result;

                    DiscoInfo di = iq.Query as DiscoInfo;

                    if (ClientName != null)
                        di.AddIdentity(new DiscoIdentity(ClientCategory.ToString(), this.ClientName, "client"));

                    foreach (string feature in ClientFeatures)
                    {
                        di.AddFeature(new DiscoFeature(feature));
                    }

                    xmppCon.Send(iq);

                }

            }
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:33,代码来源:DiscoHelper.cs

示例4: OnGetAuthInfo

        private void OnGetAuthInfo(object sender, IQ iq, object data)
        {
            // We get smth like this and should add password (digest) and ressource
            // Recv:<iq type="result" id="MX_7"><query xmlns="jabber:iq:auth"><username>gnauck</username><password/><digest/><resource/></query></iq>
            // Send:<iq type='set' id='mx_login'>
            //			<query xmlns='jabber:iq:auth'><username>gnauck</username><digest>27c05d464e3f908db3b2ca1729674bfddb28daf2</digest><resource>Office</resource></query>
            //		</iq>
            // Recv:<iq id="mx_login" type="result"/>

            iq.GenerateId();
            iq.SwitchDirection();
            iq.Type = IqType.set;

            Auth auth = (Auth) iq.Query;

            auth.Resource = this.m_Resource;
            auth.SetAuth(this.m_Username, this.m_Password, this.StreamId);

            IqGrabber.SendIq(iq, new IqCB(OnAuthenticate), null);
        }
开发者ID:jptoto,项目名称:argsxmpp,代码行数:20,代码来源:XmppClientConnection.cs

示例5: ProcessRosterIQ

 private void ProcessRosterIQ(IQ iq)
 {
     if (iq.Type == IqType.get)
     {
         // Send the roster
         // we send a dummy roster here, you should retrieve it from a
         // database or some kind of directory (LDAP, AD etc...)
         iq.SwitchDirection();
         iq.Type = IqType.result;
         for (int i=1; i<11;i++)
         {
             RosterItem ri = new RosterItem();
             ri.Name = "Item " + i.ToString();
             ri.Subscription = SubscriptionType.both;
             ri.Jid = new Jid("item" + i.ToString() + "@localhost");
             ri.AddGroup("localhost");
             iq.Query.AddChild(ri);
         }
         for (int i=1; i<11;i++)
         {
             RosterItem ri = new RosterItem();
             ri.Name = "Item JO " + i.ToString();
             ri.Subscription = SubscriptionType.both;
             ri.Jid = new Jid("item" + i.ToString() + "@jabber.org");
             ri.AddGroup("JO");
             iq.Query.AddChild(ri);
         }
         Send(iq);
     }
 }
开发者ID:phiree,项目名称:dzdocs,代码行数:30,代码来源:XmppServerConnection.cs

示例6: ProcessIQ

        private void ProcessIQ(IQ iq)
        {
            if(iq.Query.GetType() == typeof(Auth))
            {
                Auth auth = iq.Query as Auth;
                switch(iq.Type)
                {
                    case IqType.get:
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        auth.AddChild(new Element("password"));
                        auth.AddChild(new Element("digest"));
                        Send(iq);
                        break;
                    case IqType.set:
                        // Here we should verify the authentication credentials
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        iq.Query = null;
                        Send(iq);
                        break;
                }

            }
            else if(iq.Query.GetType() == typeof(Roster))
            {
                ProcessRosterIQ(iq);

            }
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:30,代码来源:XmppServerConnection.cs

示例7: ProcessIQ

        private void ProcessIQ(IQ iq)
        {
            //用户认证
            if (iq.Query.GetType() == typeof(Auth))
            {
                Auth auth = iq.Query as Auth;
                switch (iq.Type)
                {
                    case IqType.get:
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        auth.AddChild(new Element("password"));
                        auth.AddChild(new Element("digest"));
                        Send(iq);
                        break;
                    case IqType.set:
                        this.jid = new Jid(auth.Username, "localhost", "Resource");

                        Online.onlineuser.Add(this);

                        string[] subItem0 ={ auth.Username, m_Sock.RemoteEndPoint.ToString() };

                        frm.Invoke(new dosomethings(delegate()
                        {
                            frm.listBox1.Items.Add(auth.Username + "上线");
                            frm.listBox2.Items.Add(auth.Username);
                        }));
                        iq.SwitchDirection();
                        iq.Type = IqType.result;
                        iq.Query = null;
                        Send(iq);
                        break;
                }

            }
            else if (iq.Query.GetType() == typeof(Roster))
            {
                ProcessRosterIQ(iq);

            }
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:41,代码来源:XmppServerConnection.cs

示例8: XmppCon_OnIq

        private void XmppCon_OnIq(object sender, IQ iq)
        {
            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 IqHandler(XmppCon_OnIq), new object[] { sender, iq });
                return;
            }

            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();

                        XmppCon.Send(iq);
                    }
                }
            }
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:33,代码来源:frmMain.cs


注:本文中的agsXMPP.protocol.client.IQ.SwitchDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。