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


C# agsXMPP.SelectSingleElement方法代码示例

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


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

示例1: XmppCon_OnMessage

		/// <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;
			}

			// check for xData Message
			Element e = msg.SelectSingleElement(typeof(Data));
			if (e != null)
			{	
				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 (!Util.Forms.ContainsKey(msg.From.Bare))
				{
					ListViewItem itm = FindRosterListViewItem(msg.From);
					string nick =  itm == null ? msg.From.Bare : itm.Text;
				
					frmChat f = new frmChat(msg.From, XmppCon, nick);
					f.Show();
					f.IncomingMessage(msg);
				}
			}
		}
开发者ID:don59,项目名称:agsXmpp,代码行数:40,代码来源:frmMain.cs

示例2: Xmpp_OnMessage

    static void Xmpp_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
    {
        if (msg.HasTag(typeof(AgIXML)))
        {
            AgIXML agiMsg = msg.SelectSingleElement(typeof(AgIXML)) as AgIXML;
            agiMsg newMsg = new agiMsg();
            newMsg.ID = agiMsg.ID;
            newMsg.Type = agiMsg.Type;
            newMsg.Path = agiMsg.Path;
            newMsg.SessionID = agiMsg.SessionID;
            newMsg.SessionKey = agiMsg.SessionKey;
            newMsg.Data = agiMsg.Data;
            newMsg.Flags = agiMsg.Flags;

            switch (newMsg.Type)
            {
                case "tput":
                    xmppManager.world.agi.tput(newMsg);
                    break;
                case "rput":
                    xmppManager.world.agi.rput(newMsg);
                    break;
                case "tget":
                    xmppManager.world.agi.tget(newMsg);
                    break;
                case "rget":
                    xmppManager.world.agi.rget(newMsg);
                    break;
                case "tattach":
                    xmppManager.world.agi.tattach(newMsg);
                    break;
                case "rattach":
                    xmppManager.world.agi.rattach(newMsg);
                    break;
                case "tremove":
                    xmppManager.world.agi.tremove(newMsg);
                    break;
                case "rremove":
                    xmppManager.world.agi.rremove(newMsg);
                    break;
                case "tflush":
                    xmppManager.world.agi.tflush(newMsg);
                    break;
                case "rflush":
                    xmppManager.world.agi.rflush(newMsg);
                    break;
            }
        }

        if (msg.Body != null)
        {
             messages newMsg = new messages();
            newMsg.body = msg.Body;
            newMsg.from = msg.From.User;

            int count = 0;

            while (chats.Count != 0 && count < chats.Count)
            {
                if (chats.ElementAt(count).chatWith.userID == msg.From.User)
                {
                    chats.ElementAt(count).msgChain.Add(newMsg);
                    return;
                }
                count++;
            }

            chat newchat = new chat();
            newchat.msgChain.Add(newMsg);
            newchat.chatWith.userID = msg.From.User.ToString();
            chats.Add(newchat);
            Console.WriteLine(newMsg.body.ToString());
        }
    }
开发者ID:Softsurve,项目名称:Silver-Iodide,代码行数:74,代码来源:XMPPFS.cs

示例3: XmppCon_OnMessage

        /// <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);
                    }
                }
            }
        }
开发者ID:koralarts,项目名称:HipsterChat,代码行数:63,代码来源:frmMain.cs

示例4: PresenceCallback

        /// <summary>
        ///  Aqui capturo todos mensajes de precence-protocol para detectar abandonos de sala e ingresos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="pres"></param>
        /// <param name="data"></param>
        private void PresenceCallback(object sender, agsXMPP.protocol.client.Presence pres, object data)
        {
            if (InvokeRequired)
            {
		
                BeginInvoke(new PresenceCB(PresenceCallback), new object[] { sender, pres, data });
                return;
            }

            ListViewItem lvi = FindListViewItem(pres.From);
            if (lvi != null)
            {
                if (pres.Type == PresenceType.unavailable)
                {
                    lvi.Remove();
                }
                else
                {
                    int imageIdx = Util.GetRosterImageIndex(pres);
                    lvi.ImageIndex = imageIdx;
                    lvi.SubItems[1].Text = (pres.Status == null ? "" : pres.Status);
                    User u = pres.SelectSingleElement(typeof(User)) as User;
                    if (u != null)
                    {
                        lvi.SubItems[2].Text = u.Item.Affiliation.ToString();
                        lvi.SubItems[3].Text = u.Item.Role.ToString();
                    }
                }
            }
            else
            {
                int imageIdx = Util.GetRosterImageIndex(pres);
                
                ListViewItem lv = new ListViewItem(pres.From.Resource);               

                lv.Tag = pres.From.ToString();
                lv.SubItems.Add(pres.Status == null ? "" : pres.Status);
                User u = pres.SelectSingleElement(typeof(User)) as User;
                if (u != null)
                {
                    lv.SubItems.Add(u.Item.Affiliation.ToString());
                    lv.SubItems.Add(u.Item.Role.ToString());
                }
                lv.ImageIndex = imageIdx;
                lvwRoster.Items.Add(lv);
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:53,代码来源:frmGroupChat.cs

示例5: xmppOnMessage

 /// <summary>
 /// Se produit lorsqu'un message est disponible
 /// </summary>
 /// <param name="sender">Objet parent</param>
 /// <param name="message">Message en question</param>
 private void xmppOnMessage(object sender, agsXMPP.protocol.client.Message message)
 {
     if (message.From != null)
     {
         string bare = message.From.Bare;
         if (message.From.Resource != null && message.Nickname != null)
         {
             if (contacts.ContainsKey(bare) && contacts[bare].ContainsKey(message.From.Resource) && message.Nickname.ToString().Trim() != string.Empty)
             {
                 contacts[bare][message.From.Resource].identity.nickname = message.Nickname.ToString().Trim();
             }
         }
         if (message.HasTag("event"))
         {
             agsXMPP.Xml.Dom.Element evt = message.SelectSingleElement("event");
             if (evt.Namespace == "http://jabber.org/protocol/pubsub#event" && evt.HasChildElements)
             {
                 #region PubSub Events
                 // HACK: Bug serveur. Suivant la XEP c'est Items, ejabberd2.0 retourne parfois Item sans S
                 if (evt.HasTag("items") || evt.HasTag("item"))
                 {
                     agsXMPP.Xml.Dom.Element items = evt.SelectSingleElement("items");
                     if (items == null)
                     {
                         items = evt.SelectSingleElement("item");
                     }
                     if (items.HasTag("item"))
                     {
                         agsXMPP.Xml.Dom.Element item = items.SelectSingleElement("item");
                         // TODO: g�rer le User mood dans les messages chat
                         #region User mood
                         if (items.HasAttribute("node") && (items.Attributes["node"] as string) == "http://jabber.org/protocol/mood" && (item.HasTag("mood") || item.HasTag("retract")))
                         {
                             agsXMPP.Xml.Dom.Element mood = item.SelectSingleElement("mood");
                             if (mood != null)
                             {
                                 // HACK: mood.Namespace == "http://jabber.org/protocol/mood"
                                 if (mood.HasChildElements)
                                 {
                                     Enumerations.MoodType moodType = Enumerations.MoodType.none;
                                     foreach (Enumerations.MoodType mt in Enum.GetValues(typeof(Enumerations.MoodType)))
                                     {
                                         string mtn = Enum.GetName(typeof(Enumerations.MoodType), mt);
                                         if (mood.HasTag(mtn))
                                         {
                                             moodType = mt;
                                             break;
                                         }
                                     }
                                     string moodString = string.Empty;
                                     if (mood.HasTag("text") && mood.SelectSingleElement("text").Value != null)
                                     {
                                         moodString = mood.SelectSingleElement("text").Value.Trim();
                                     }
                                     if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                     {
                                         foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                         {
                                             Mood md = new Mood();
                                             md.type = moodType;
                                             md.text = moodString;
                                             r.Value.mood = md;
                                             OnMoodUpdated(r.Value, r.Value.mood);
                                         }
                                     }
                                     else
                                     {
                                         Mood md = new Mood();
                                         md.type = moodType;
                                         md.text = moodString;
                                         UserPEP up = new UserPEP();
                                         up.mood = md;
                                         if (!initialUserPEP.ContainsKey(bare))
                                         {
                                             initialUserPEP.Add(bare, up);
                                         }
                                         else
                                         {
                                             up.tune = initialUserPEP[bare].tune;
                                             up.activity = initialUserPEP[bare].activity;
                                             up.location = initialUserPEP[bare].location;
                                             initialUserPEP[bare] = up;
                                         }
                                     }
                                 }
                             }
                             else if (item.SelectSingleElement("retract") != null)
                             {
                                 if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                 {
                                     foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                     {
                                         Mood md = new Mood();
                                         md.type = Enumerations.MoodType.none;
                                         md.text = string.Empty;
//.........这里部分代码省略.........
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:101,代码来源:Roster.cs

示例6: XmppCon_OnIq

        private void XmppCon_OnIq(object sender, agsXMPP.protocol.client.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;
            }
                       

            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
                            Console.WriteLine(file.Size.ToString());
                            Console.WriteLine(file.Name);
                            frmFileTransfer frmFile = new frmFileTransfer(XmppCon, iq);
                            frmFile.Show();
                        }
                    }
                }                
                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();

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

示例7: ElementError

 /// <summary>
 /// XMPP
 /// </summary>
 /// <param name="sender">Objet parent</param>
 /// <param name="el">Element</param>
 private void ElementError(object sender, agsXMPP.Xml.Dom.Element el)
 {
     if (el.HasTag("error", true)) {
         agsXMPP.Xml.Dom.Element e = el.SelectSingleElement("error", true);
         int code = 0;
         if (e.HasAttribute("code")) { code = Convert.ToInt32(e.Attribute("code")); }
         switch (code) {
             case 302:
                 OnErrorRaised(Enums.ErrorType.Query, "Request redirected.");
                 break;
             case 400:
                 OnErrorRaised(Enums.ErrorType.Query, "Bad Request.");
                 break;
             case 401:
                 OnErrorRaised(Enums.ErrorType.Authentification, "Account not authorized.");
                 break;
             case 402:
                 OnErrorRaised(Enums.ErrorType.Authentification, "Account incorrect.");
                 break;
             case 403:
                 OnErrorRaised(Enums.ErrorType.Authentification, "Account denied.");
                 break;
             case 404:
                 OnErrorRaised(Enums.ErrorType.Warning, "Request discontinued.");
                 break;
             case 405:
                 OnErrorRaised(Enums.ErrorType.Warning, "Request prohibited.");
                 break;
             case 406:
                 OnErrorRaised(Enums.ErrorType.Query, "Request not authorized.");
                 break;
             case 407:
                 OnErrorRaised(Enums.ErrorType.Authentification, "Account not registered.");
                 break;
             case 408:
                 OnErrorRaised(Enums.ErrorType.Server, "Server Timeout.");
                 break;
             case 409:
                 OnErrorRaised(Enums.ErrorType.Warning, "Conflicting request.");
                 break;
             case 500:
                 OnErrorRaised(Enums.ErrorType.Server, "Internal error.");
                 break;
             case 501:
                 OnErrorRaised(Enums.ErrorType.Warning, "Request not implemented.");
                 break;
             case 502:
                 OnErrorRaised(Enums.ErrorType.Server, "Distant error.");
                 break;
             case 503:
                 OnErrorRaised(Enums.ErrorType.Warning, "Service temporarily not available.");
                 break;
             case 504:
                 OnErrorRaised(Enums.ErrorType.Server, "Distant time limit reached.");
                 break;
             case 510:
                 OnErrorRaised(Enums.ErrorType.Warning, "Disconnected.");
                 break;
             default:
                 OnErrorRaised(Enums.ErrorType.Client, "General error.");
                 break;
         }
     } else {
         if (el.HasTag("bad-request", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Request incorrect.");
         } else if (el.HasTag("conflict", true)) {
             OnErrorRaised(Enums.ErrorType.Warning, "Conflicting request.");
         } else if (el.HasTag("feature-not-implemented", true)) {
             OnErrorRaised(Enums.ErrorType.Warning, "Request not implemented.");
         } else if (el.HasTag("forbidden", true)) {
             OnErrorRaised(Enums.ErrorType.Authentification, "Account not authorized.");
         } else if (el.HasTag("gone", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Request redirected.");
         } else if (el.HasTag("internal-server-error", true)) {
             OnErrorRaised(Enums.ErrorType.Server, "Internal error.");
         } else if (el.HasTag("item-not-found", true)) {
             OnErrorRaised(Enums.ErrorType.Warning, "Request discontinued.");
         } else if (el.HasTag("jid-malformed", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Jabber ID incorrect.");
         } else if (el.HasTag("not-acceptable", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Request not accepted.");
         } else if (el.HasTag("not-allowed", true)) {
             OnErrorRaised(Enums.ErrorType.Server, "Operation not allowed");
         } else if (el.HasTag("not-authorized", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Request not authorized.");
         } else if (el.HasTag("payment-required", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Finalisation requise.");
         } else if (el.HasTag("recipient-unavailable", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Recipient unavailable.");
         } else if (el.HasTag("redirect", true)) {
             OnErrorRaised(Enums.ErrorType.Query, "Request redirected.");
         } else if (el.HasTag("registration-required", true)) {
             OnErrorRaised(Enums.ErrorType.Authentification, "Account not registered.");
         } else if (el.HasTag("remote-server-not-found", true)) {
             OnErrorRaised(Enums.ErrorType.Server, "Distant error.");
//.........这里部分代码省略.........
开发者ID:kevinmel2000,项目名称:mychitchat,代码行数:101,代码来源:ErrorManager.cs

示例8: ElementError

 /// <summary>
 /// XMPP
 /// </summary>
 /// <param name="sender">Objet parent</param>
 /// <param name="el">Element</param>
 private void ElementError(object sender, agsXMPP.Xml.Dom.Element el)
 {
     if (el.HasTag("error", true))
     {
         agsXMPP.Xml.Dom.Element e = el.SelectSingleElement("error", true);
         int code = 0;
         if (e.HasAttribute("code")) { code = Convert.ToInt32(e.Attribute("code")); }
         switch (code)
         {
             case 302:
                 OnErrorRaised(Enumerations.ErrorType.Query, "Demande redirig�.");
                 break;
             case 400:
                 OnErrorRaised(Enumerations.ErrorType.Query, "Demande incorrecte.");
                 break;
             case 401:
                 OnErrorRaised(Enumerations.ErrorType.Authentification, "Compte non autauris�.");
                 break;
             case 402:
                 OnErrorRaised(Enumerations.ErrorType.Authentification, "Compte incorrect.");
                 break;
             case 403:
                 OnErrorRaised(Enumerations.ErrorType.Authentification, "Compte refus�.");
                 break;
             case 404:
                 OnErrorRaised(Enumerations.ErrorType.Warning, "Demande inconnue.");
                 break;
             case 405:
                 OnErrorRaised(Enumerations.ErrorType.Warning, "Demande interdite.");
                 break;
             case 406:
                 OnErrorRaised(Enumerations.ErrorType.Query, "Demande non autoris�e.");
                 break;
             case 407:
                 OnErrorRaised(Enumerations.ErrorType.Authentification, "Compte non enregistr�.");
                 break;
             case 408:
                 OnErrorRaised(Enumerations.ErrorType.Server, "Temps limite atteint.");
                 break;
             case 409:
                 OnErrorRaised(Enumerations.ErrorType.Warning, "Demande en conflit.");
                 break;
             case 500:
                 OnErrorRaised(Enumerations.ErrorType.Server, "Erreur interne.");
                 break;
             case 501:
                 OnErrorRaised(Enumerations.ErrorType.Warning, "Demande non impl�ment�e.");
                 break;
             case 502:
                 OnErrorRaised(Enumerations.ErrorType.Server, "Erreur distante.");
                 break;
             case 503:
                 OnErrorRaised(Enumerations.ErrorType.Warning, "Service temporairement innaccessible.");
                 break;
             case 504:
                 OnErrorRaised(Enumerations.ErrorType.Server, "Temps limite distant atteint.");
                 break;
             case 510:
                 OnErrorRaised(Enumerations.ErrorType.Warning, "D�connect�.");
                 break;
             default:
                 OnErrorRaised(Enumerations.ErrorType.Client, "Erreur g�n�rale.");
                 break;
         }
     }
     else
     {
         if (el.HasTag("bad-request", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Demande incorrecte."); }
         else if (el.HasTag("conflict", true)) { OnErrorRaised(Enumerations.ErrorType.Warning, "Demande en conflit."); }
         else if (el.HasTag("feature-not-implemented", true)) { OnErrorRaised(Enumerations.ErrorType.Warning, "Demande non impl�ment�e."); }
         else if (el.HasTag("forbidden", true)) { OnErrorRaised(Enumerations.ErrorType.Authentification, "Compte non autoris�."); }
         else if (el.HasTag("gone", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Demande redirig�e"); }
         else if (el.HasTag("internal-server-error", true)) { OnErrorRaised(Enumerations.ErrorType.Server, "Erreur interne."); }
         else if (el.HasTag("item-not-found", true)) { OnErrorRaised(Enumerations.ErrorType.Warning, "El�ment inconnu."); }
         else if (el.HasTag("jid-malformed", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Jabber ID incorrect."); }
         else if (el.HasTag("not-acceptable", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Demande non accept�e."); }
         else if (el.HasTag("not-allowed", true)) { OnErrorRaised(Enumerations.ErrorType.Server, "Op�ration non autoris�e."); }
         else if (el.HasTag("not-authorized", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Demande non autoris�e."); }
         else if (el.HasTag("payment-required", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Finalisation requise."); }
         else if (el.HasTag("recipient-unavailable", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Destinataire non disponible."); }
         else if (el.HasTag("redirect", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Demande redirig�."); }
         else if (el.HasTag("registration-required", true)) { OnErrorRaised(Enumerations.ErrorType.Authentification, "Compte non enregistr�."); }
         else if (el.HasTag("remote-server-not-found", true)) { OnErrorRaised(Enumerations.ErrorType.Server, "Erreur distante."); }
         else if (el.HasTag("remote-server-timeout", true)) { OnErrorRaised(Enumerations.ErrorType.Server, "Temps limite distant atteint."); }
         else if (el.HasTag("resource-constraint", true)) { OnErrorRaised(Enumerations.ErrorType.Authentification, "Ressource valide requise."); }
         else if (el.HasTag("service-unavailable", true)) { OnErrorRaised(Enumerations.ErrorType.Warning, "Service temporairement innaccessible."); }
         else if (el.HasTag("subscription-required", true)) { OnErrorRaised(Enumerations.ErrorType.Client, "Abonnement requis."); }
         else if (el.HasTag("undefined-condition", true)) { OnErrorRaised(Enumerations.ErrorType.Client, "Condition inconnue."); }
         else if (el.HasTag("unexpected-request", true)) { OnErrorRaised(Enumerations.ErrorType.Query, "Demande incorrecte."); }
     }
 }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:96,代码来源:ErrorManager.cs

示例9: xmppConnection_OnMessage

        void xmppConnection_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            //Trace.WriteLine(msg.ToString());
            if (msg.From.Bare != ServiceSender)
                return;

            Element entryE = msg.SelectSingleElement("entry");
            Element sourceE = entryE.SelectSingleElement("source");
            Element authorE = sourceE.SelectSingleElement("author");

            User user = new User
            {
                Description = authorE.GetTag("description"),
                Id = authorE.GetTagInt("twitter_id"),
                Location = authorE.GetTag("location"),
                Protected = authorE.GetTagBool("protected"),
                Name = authorE.GetTag("name"),
                ScreenName = authorE.GetTag("screen_name"),
                Url = authorE.GetTag("url"),
                ProfileImageUrl = authorE.GetTag("profile_image_url")
            };

            String body = msg.Body;
            if (body.IndexOf(": ") > -1)
                body = body.Substring(body.IndexOf(": ") + 2);

            Status status = new Status
            {
                CreatedAt = DateTime.Parse(entryE.GetTag("published")),
                Text = body,
                User = user,
                Id = entryE.GetTagInt((entryE.GetTagInt("twitter_id") == 0 ? "status_id" : "twitter_id")) // HACK: 何故かどっちかでくる
            };

            OnStatusUpdateReceived(status);
        }
开发者ID:argrath,项目名称:TwitterIRCGatewayOld,代码行数:36,代码来源:TwitterIMService.cs

示例10: XmppCon_OnMessage

        /// <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;
            }

            // check for xData Message
            Element e = msg.SelectSingleElement(typeof(Data));
            if (e != null)
            {
                Data xdata = e as Data;
                if (xdata.Type == XDataFormType.form)
                {
                    // This is not supported by the WM5 MiniClient sample
                }
            }
            else
            {
                if (msg.Type == MessageType.chat)
                {
                    if (!Util.Forms.ContainsKey(msg.From.Bare))
                    {
                        ListViewItem itm = FindRosterListViewItem(msg.From);
                        string nick = itm == null ? msg.From.Bare : itm.Text;

                        frmChat f = new frmChat(msg.From, XmppCon, nick);
                        f.Show();
                        f.IncomingMessage(msg);
                    }
                }
                else if (msg.Type == MessageType.normal)
                {
                    frmMsg fMsg = new frmMsg(msg);
                    fMsg.Show();
                }
                else if (msg.Type == MessageType.headline)
                {
                    // not handeled in this example
                }
            }
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:50,代码来源:frmMain.cs

示例11: SwitchIQ

        public void SwitchIQ(agsXMPP.protocol.client.IQ iq)
        {
            if (iq == null) return;


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

                    agsXMPP.protocol.extensions.filetransfer.File file = si.File;
                    if (file != null)
                    {
                        // somebody wants to send a file to us
                        AddLog(string.Concat("Alguien esta enviando un archivo Size:", file.Size.ToString(), " nombre: ", file.Name));

                        //frmFileTransfer frmFile = new frmFileTransfer(XmppCon, iq);
                        //frmFile.Show();
                    }
                }
            }

            if (iq.Type == IqType.error)
            {
                //if (iq.Error.Code == agsXMPP.protocol.client.ErrorCode.NotFound)
                //{
                    string msg = string.Concat(iq.From ," ", iq.Error.Condition);
                    AddLog(msg);
                //}
            }

            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;
                        //XmppCon.Send(iq);
                    }
                    else if (iq.Query is DiscoItems)
                    {
                        //iq.SwitchDirection();
                        //iq.Type = IqType.error;
                        //iq.Error = new Error(ErrorType.cancel, ErrorCondition.FeatureNotImplemented);
                        //XmppCon.Send(iq);
                    }
                    else if (iq.Query is agsXMPP.protocol.iq.version.Version)
                    {
                        //Suichea  from y to
                        iq.SwitchDirection();
                        iq.Type = IqType.result;//indica retorno o respuesta

                        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();
                        Util.XmppServices.XmppCon.Send(iq);
                        //frmMain.AddLog("IQ: tipo vesion");
                    }
                    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);
                        Util.XmppServices.XmppCon.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;
                        Util.XmppServices.XmppCon.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);
//.........这里部分代码省略.........
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:101,代码来源:Util.cs


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