Example #1
0
        private void OnPubSubCreateNode(object sender, IqEventArgs e)
        {
            m_bReady = false;
            var error = e.Iq.Element <Error>();

            if (e.Iq.Type == Matrix.Xmpp.IqType.result)
            {
                Debug.WriteLine("Node [" + m_node + "] is created!");
                m_bReady = true;
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
            {
                if (error != null)
                {
                    if (error.Condition == Matrix.Xmpp.Base.ErrorCondition.Conflict)
                    {
                        Debug.WriteLine("Node [" + m_node + "] is already exist!");
                        m_bReady = true;
                    }
                    else
                    {
                        Debug.WriteLine("creation of node [{0}] failed!\r\nError Condition: {1}\r\nError Type: {2}", m_node, error.Condition, error.Type);
                    }
                }
            }

            if ((m_bReady) && (m_node != null))
            {
                SensorCreateEventArgs sce = new SensorCreateEventArgs(m_bReady);
                OnSensorCreateEvent(sce);
            }
        }
Example #2
0
        void DiscoItemsResult(object sender, IqEventArgs e)
        {
            //<iq from="vm-debian" to="alex@vm-debian/MatriX" id="MX_4" type="result" xmlns="jabber:client">
            //  <query xmlns="http://jabber.org/protocol/disco#items">
            //      <item jid="conference.vm-debian" />
            //      <item jid="irc.vm-debian" />
            //      <item jid="pubsub.vm-debian" />
            //      <item jid="vjud.vm-debian" />
            //  </query>
            //</iq>

            var query = e.Iq.Element <Matrix.Xmpp.Disco.Items>();

            if (query != null)
            {
                foreach (var itm in query.GetItems())
                {
                    // some servers have problems ifwe flood them weith too many packets here
                    // the sleep is a hack to avpid this problems.
                    //System.Threading.Thread.Sleep(200);
                    //_dm.DiscoverInformation(itm.Jid, itm.Node);
                    _dm.DiscoverInformation(itm.Jid, itm.Node, new EventHandler <IqEventArgs>(DiscoInfoResult));
                }
            }
        }
Example #3
0
        void DiscoGroupsResult(object sender, IqEventArgs e)
        {
            var query = e.Iq.Element <Matrix.Xmpp.Disco.Items>();

            if (query != null)
            {
                //
                int      i     = 0;
                int      c     = query.GetItems().Count();
                string[] rooms = new string[c];

                foreach (var itm in query.GetItems())
                {
                    rooms[i] = itm.Jid;
                    i++;
                    //_dm.DiscoverInformation(itm.Jid, itm.Node);
                    //System.Threading.Thread.Sleep(200);
                    //this.discoManager.DiscoverInformation(itm.Jid, itm.Node, new EventHandler<IqEventArgs>(DiscoInfoResult));
                }

                if (OnListGroup != null)
                {
                    this.OnListGroup(this, rooms);
                }
            }
        }
Example #4
0
        // Invoked just after the creation (or retrieving) the node.
        // If newly created or already exists, then subscribe (or other operations) can be carried out.
        // otherwise, no-op.
        private void OnPubSubCreateNode(object sender, IqEventArgs e)
        {
            m_bCreated = false;
            var error = e.Iq.Element <Error>();

            if (e.Iq.Type == Matrix.Xmpp.IqType.result)
            {
                Debug.WriteLine("node is created!");
                m_bCreated = true;
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
            {
                if (error != null)
                {
                    if (error.Condition == Matrix.Xmpp.Base.ErrorCondition.Conflict)
                    {
                        Debug.WriteLine("Node is already exist!");
                        m_bCreated = true;
                    }
                    else
                    {
                        Debug.WriteLine("creation of node failed!\r\nError Condition: {0}\r\nError Type: {1}", error.Condition, error.Type);
                    }
                }
            }
        }
 internal ValidateStreamEventArgs(XmppClient Client, IqEventArgs e, string StreamId, int BlockSize)
     : base(e)
 {
     this.client    = Client;
     this.streamId  = StreamId;
     this.blockSize = BlockSize;
 }
Example #6
0
        private void UnblockPushHandler(object Sender, IqEventArgs e)
        {
            XmlElement E;
            string     JID;
            bool       Found = false;

            lock (this.blockList)
            {
                foreach (XmlNode N in e.Query.ChildNodes)
                {
                    E = N as XmlElement;
                    if (E != null && E.LocalName == "item")
                    {
                        Found = true;
                        JID   = XML.Attribute(E, "jid");
                        this.blockList.Remove(JID);
                    }
                }

                if (!Found)
                {
                    this.blockList.Clear();
                }
            }
        }
        private void RemovedHandler(object Sender, IqEventArgs e)
        {
            XmlElement     E         = e.Query;
            string         NodeId    = XML.Attribute(E, "id");
            string         SourceId  = XML.Attribute(E, "src");
            string         Partition = XML.Attribute(E, "pt");
            ThingReference Node;

            if (string.IsNullOrEmpty(NodeId) && string.IsNullOrEmpty(SourceId) && string.IsNullOrEmpty(Partition))
            {
                Node = ThingReference.Empty;
            }
            else
            {
                Node = new ThingReference(NodeId, SourceId, Partition);
            }

            NodeEventArgs    e2 = new NodeEventArgs(e, Node);
            NodeEventHandler h  = this.Removed;

            if (h != null)
            {
                try
                {
                    h(this, e2);
                }
                catch (Exception ex)
                {
                    Log.Critical(ex);
                }
            }

            e.IqResult(string.Empty);
        }
Example #8
0
 private void VcardUpdateResponse(object sender, IqEventArgs e)
 {
     if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
     {
         MessageBox.Show("The VCard was updated successful!!");
     }
 }
Example #9
0
        private void CancelHandler(object Sender, IqEventArgs e)
        {
            SensorDataServerRequest Request;
            string Id  = XML.Attribute(e.Query, "id");
            string Key = e.From + " " + Id;

            lock (this.requests)
            {
                if (this.requests.TryGetValue(Key, out Request))
                {
                    this.requests.Remove(Key);
                }
                else
                {
                    Request = null;
                }
            }

            if (Request != null && !Request.Started)
            {
                this.scheduler.Remove(Request.When);
            }

            e.IqResult(string.Empty);
        }
Example #10
0
        private void OpenHandler(object Sender, IqEventArgs e)
        {
            int    BlockSize = XML.Attribute(e.Query, "block-size", 0);
            string StreamId  = XML.Attribute(e.Query, "sid");
            string Stanza    = XML.Attribute(e.Query, "stanza", "iq");

            if (Stanza != "message" && Stanza != "iq")
            {
                throw new BadRequestException("Invalid stanza type.", e.IQ);
            }

            if (BlockSize <= 0)
            {
                throw new BadRequestException("Invalid block size.", e.IQ);
            }

            if (BlockSize > this.maxBlockSize)
            {
                throw new ResourceConstraintException("Requested block size too large. Maximum acceptable is " +
                                                      this.maxBlockSize.ToString(), e.IQ);
            }

            ValidateStreamEventHandler h  = this.OnOpen;
            ValidateStreamEventArgs    e2 = new ValidateStreamEventArgs(this.client, e, StreamId, BlockSize);

            if (h != null)
            {
                try
                {
                    h(this, e2);
                }
                catch (Exception ex)
                {
                    Log.Critical(ex);
                }
            }

            if (e2.DataCallback is null || e2.CloseCallback is null)
            {
                throw new NotAcceptableException("Stream not expected.", e.IQ);
            }

            this.AssertCacheCreated();

            string Key = e.From + " " + StreamId;

            if (this.cache.ContainsKey(Key))
            {
                throw new NotAcceptableException("Stream already open.", e.IQ);
            }

            IncomingStream Input = new IncomingStream(e2.DataCallback, e2.CloseCallback, e2.State, BlockSize);

            this.cache[Key] = Input;

            e.IqResult(string.Empty);
        }
Example #11
0
        private Task CloseHandler(object Sender, IqEventArgs e)
        {
            string         StreamId = XML.Attribute(e.Query, "sid");
            string         Key      = e.From + " " + StreamId;
            IncomingStream Input;
            OutgoingStream Output;

            lock (this.synchObject)
            {
                if (this.cache is null)
                {
                    Input = null;
                }
                else if (this.cache.TryGetValue(Key, out Input))
                {
                    this.cache.Remove(Key);
                }
                else
                {
                    Input = null;
                }
            }

            if (Input is null)
            {
                lock (this.output)
                {
                    if (!this.output.TryGetValue(StreamId, out Output))
                    {
                        throw new ItemNotFoundException("Stream not recognized.", e.Query);
                    }

                    this.output.Remove(StreamId);
                }

                Output.Abort();
                Output.Dispose();
            }
            else
            {
                if (Input.BlocksMissing)
                {
                    Input.Closed(CloseReason.Aborted);
                }
                else
                {
                    Input.Closed(CloseReason.Done);
                }

                Input.Dispose();
            }

            e.IqResult(string.Empty);

            return(Task.CompletedTask);
        }
Example #12
0
 private void PublishResult(object sender, IqEventArgs e)
 {
     if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
     {
     }
     else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
     {
         // handle error here.
     }
 }
Example #13
0
 private void DataHandler(object Sender, IqEventArgs e)
 {
     if (this.HandleIncomingData(e.Query, e.From))
     {
         e.IqResult(string.Empty);
     }
     else
     {
         throw new ItemNotFoundException("Stream not recognized.", e.Query);
     }
 }
Example #14
0
 private void SubscribeResult(object sender, IqEventArgs e)
 {
     if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
     {
         MessageBox.Show(String.Format("You are now subscribed to the node: {0}", e.State as string));
     }
     else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
     {
         // handle error here.
     }
 }
Example #15
0
 private async void QueryVCardHandler(object Sender, IqEventArgs e)
 {
     try
     {
         e.IqResult(await this.GetVCardXml());
     }
     catch (Exception ex)
     {
         e.IqError(ex);
     }
 }
Example #16
0
        private void RosterResponse(object sender, IqEventArgs e)
        {
            var iq = e.Iq;

            if (iq.Type == IqType.Result)
            {
                // process result here
            }
            else if (iq.Type == IqType.Error)
            {
                // process errors here
            }
        }
Example #17
0
        private void VcardResponse(object sender, IqEventArgs e)
        {
            if (e.Iq.Type == Matrix.Xmpp.IqType.result)
            {
                var vc = e.Iq.Query as Vcard;
                txtName.Text = vc.Fullname;
                txtNickname.Text = vc.Nickname;

                var  email = vc.GetEmails().FirstOrDefault(m => m.IsInternet);
                if (email != null)
                    txtEmail.Text = email.Address;
            }
        }
Example #18
0
        private void ForwardedTokenChallengeResponse(object Sender, IqResultEventArgs e2)
        {
            IqEventArgs e = (IqEventArgs)e2.State;

            if (e2.Ok)
            {
                e.IqResult(e2.FirstElement.OuterXml);
            }
            else
            {
                e.IqError(e2.ErrorElement.OuterXml);
            }
        }
Example #19
0
        private void OnPubSubDeleteNode(object sender, IqEventArgs e)
        {
            var pubsub = e.Iq.Element <Matrix.Xmpp.PubSub.PubSub>();
            var error  = e.Iq.Element <Error>();

            if (e.Iq.Type == Matrix.Xmpp.IqType.result)
            {
                Debug.WriteLine("node [" + m_node + "] is deleted!");
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
            {
                Debug.WriteLine("creation of node [{0}] failed!\r\nError Condition: {1}\r\nError Type: {2}", m_node, error.Condition, error.Type);
            }
        }
Example #20
0
        private void GetData(object Sender, IqEventArgs e)
        {
            string ContentId = XML.Attribute(e.Query, "cid");
            string FileName  = this.GetFileName(ContentId);

            if (!File.Exists(FileName))
            {
                throw new ItemNotFoundException("Content not found.", e.Query);
            }

            string Xml = File.ReadAllText(FileName, Encoding.ASCII);

            e.IqResult(Xml);
        }
Example #21
0
        void DiscoPubSubNodesResult(object sender, IqEventArgs e)
        {
            var query = e.Iq.Element <Matrix.Xmpp.Disco.Items>();

            if (query != null)
            {
                foreach (var item in query.GetItems())
                {
                    // this seems recursive?
                    //Log.Info("ASDF "  + item.Name + " " + item.Node + " " + item.Jid);
                    DiscoPubSubNodes(item.Jid, item.Node);
                }
            }
        }
Example #22
0
        private void VcardResponse(object sender, IqEventArgs e)
        {
            if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
            {
                var vc = e.Iq.Query as Vcard;
                txtName.Text     = vc.Fullname;
                txtNickname.Text = vc.Nickname;

                var email = vc.GetEmails().FirstOrDefault(m => m.IsInternet);
                if (email != null)
                {
                    txtEmail.Text = email.Address;
                }
            }
        }
Example #23
0
 void _xmppClient_OnIq(object sender, IqEventArgs e)
 {
     if (e.Iq.From != null && e.Iq.From.Bare == "search." + FrmLogin.Instance.HostName)
     {
         var query = e.Iq.Element <Matrix.Xmpp.Search.Search>();
         foreach (var itm in query.GetItems())
         {
             var newItem = new RosterListViewItem(itm.Nick ?? itm.Jid.Bare, 0, null)
             {
                 Name = itm.Jid.Bare
             };
             listSearchContracts.Items.Add(newItem);
         }
     }
 }
Example #24
0
        void DiscoItemsResult(object sender, IqEventArgs e)
        {
            var query = e.Iq.Element <Matrix.Xmpp.Disco.Items>();

            if (query != null)
            {
                foreach (var itm in query.GetItems())
                {
                    //_dm.DiscoverInformation(itm.Jid, itm.Node);
                    System.Threading.Thread.Sleep(200);
                    Log.Info("Disco: " + itm.Jid);
                    this.discoManager.DiscoverInformation(itm.Jid, itm.Node, new EventHandler <IqEventArgs>(DiscoInfoResult));
                }
            }
        }
Example #25
0
        private void VcardResponse(object sender, IqEventArgs e)
        {
            if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
            {
                var vc = e.Iq.Query as Vcard;
                UserName = vc.Fullname;

                if (!Util.ChatForms.ContainsKey(Group.Name))
                {
                    var roomJid = new Jid(Group.Name);
                    var f       = new FrmGroupChat(xmppClient, roomJid, UserName, listContacts);
                    f.MdiParent = FrmParent.Instance;
                    f.Show();
                }
            }
        }
Example #26
0
 private void DeleteNodeResult(object sender, IqEventArgs e)
 {
     if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
     {
         var pNode = e.State as DiscoNode;
         if (pNode != null)
         {
             MessageBox.Show(String.Format("node {0} was deleted!", pNode.Node));
             pNode.Remove();
         }
     }
     else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
     {
         // handle error here.
     }
 }
Example #27
0
        /// <summary>
        /// Sets parameters from a data form in a set of objects.
        /// </summary>
        /// <param name="e">IQ Event Arguments describing the request.</param>
        /// <param name="EditableObjects">Objects whose parameters will be set.</param>
        /// <param name="Form">Data Form.</param>
        /// <returns>Any errors encountered, or null if parameters was set properly.</returns>
        public static async Task <KeyValuePair <string, string>[]> SetEditableForm(IqEventArgs e, IEnumerable <object> EditableObjects, DataForm Form)
        {
            KeyValuePair <string, string>[] Result;

            foreach (Object EditableObject in EditableObjects)
            {
                Result = await SetEditableForm(e, EditableObject, Form);

                if (Result != null)
                {
                    return(Result);
                }
            }

            return(null);
        }
Example #28
0
        private void CreateInstantNodeResult(object sender, IqEventArgs e)
        {
            if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
            {

                var pubsub = e.Iq.Element<PubSub>();
                if (pubsub != null)
                {
                    if (pubsub.Create != null)
                        MessageBox.Show(String.Format("node {0} was created!", pubsub.Create.Node));
                }
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
            {
                // handle error here.
            }
        }
Example #29
0
        void DiscoInfoResult(object sender, IqEventArgs e)
        {
            var query = e.Iq.Element <Matrix.Xmpp.Disco.Info>();

            if (query != null)
            {
                foreach (var id in query.GetIdentities())
                {
                    if (id.Category == "pubsub")
                    {
                        Log.Info(e.Iq.From);
                        DiscoPubSubNodes(e.Iq.From, null);
                    }
                    Log.Info("DiscoInfo " + id.Category);
                }
            }
        }
Example #30
0
        private async Task GetData(object Sender, IqEventArgs e)
        {
            string ContentId = XML.Attribute(e.Query, "cid");
            string FileName  = this.GetFileName(ContentId);

            if (!File.Exists(FileName))
            {
                throw new ItemNotFoundException("Content not found.", e.Query);
            }

            using (FileStream f = File.OpenRead(FileName))
            {
                StreamReader r   = new StreamReader(f, Encoding.ASCII);
                string       Xml = await r.ReadToEndAsync();

                e.IqResult(Xml);
            }
        }
Example #31
0
        void DiscoInfoResult(object sender, IqEventArgs e)
        {
            var query = e.Iq.Element <Info>();

            if (query != null)
            {
                foreach (var id in query.GetIdentities())
                {
                    if (id.Category == "pubsub")
                    {
                        cboService.Items.Add(e.Iq.From);
                        var newnode = new DiscoNode(e.Iq.From, null, e.Iq.From);
                        treeNodes.Nodes.Add(newnode);
                        DiscoPubSubNodes(e.Iq.From, null, newnode);
                    }
                }
            }
        }
Example #32
0
        private void BlockPushHandler(object Sender, IqEventArgs e)
        {
            XmlElement E;
            string     JID;

            lock (this.blockList)
            {
                foreach (XmlNode N in e.Query.ChildNodes)
                {
                    E = N as XmlElement;
                    if (E != null && E.LocalName == "item")
                    {
                        JID = XML.Attribute(E, "jid");
                        this.blockList[JID] = true;
                    }
                }
            }
        }
Example #33
0
 private void xmppClient_OnRegisterError(object sender, IqEventArgs e)
 {
     xmppClient.Close();
 }
Example #34
0
 protected void OnSubscribe(object sender, IqEventArgs e)
 {
     var error = e.Iq.Element<Error>();
 }
Example #35
0
 private void SubscribeResult(object sender, IqEventArgs e)
 {
     if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
     {
         MessageBox.Show(String.Format("You are now subscribed to the node: {0}", e.State as string));
     }
     else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
     {
         // handle error here.
     }
 }
Example #36
0
 void _xmppClient_OnIq(object sender, IqEventArgs e)
 {
     if (e.Iq.From != null && e.Iq.From.Bare == "search." + FrmLogin.Instance.HostName)
     {
         var query = e.Iq.Element<Matrix.Xmpp.Search.Search>();
         foreach (var itm in query.GetItems())
         {
             var newItem = new RosterListViewItem(itm.Nick ?? itm.Jid.Bare, 0, null) { Name = itm.Jid.Bare };
             listSearchContracts.Items.Add(newItem);
         }
     }
 }
Example #37
0
        private void OnPubSubCreateNode(object sender, IqEventArgs e)
        {
            m_bReady = false;
            var error = e.Iq.Element<Error>();

            if (e.Iq.Type == Matrix.Xmpp.IqType.result)
            {
                Debug.WriteLine("Node [" + m_node + "] is created!");
                m_bReady = true;
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
            {
                if (error != null)
                {
                    if (error.Condition == Matrix.Xmpp.Base.ErrorCondition.Conflict)
                    {
                        Debug.WriteLine("Node [" + m_node + "] is already exist!");
                        m_bReady = true;
                    }
                    else
                    {
                        Debug.WriteLine("creation of node [{0}] failed!\r\nError Condition: {1}\r\nError Type: {2}", m_node, error.Condition, error.Type);
                    }
                }
            }

            if ((m_bReady) && (m_node != null))
            {
                SensorCreateEventArgs sce = new SensorCreateEventArgs(m_bReady);
                OnSensorCreateEvent(sce);
            }
        }
Example #38
0
        private void xmppClient_OnIq(object sender, IqEventArgs e)
        {
            DisplayEvent("OnIq");

            if (e.Iq.Type == IqType.get &&
                e.Iq.Query is Weather)
            {
                var weather = e.Iq.Query as Weather;
                string zip = weather.Zip;
                // here you should lookup the weather information for the given zip code in a database or webservice
                // we just return some random numbers

                var temp = new Random().Next(-10, 40);
                var humidity = new Random().Next(10, 90);

                var wiq = new WeatherIq
                              {
                                  To = e.Iq.From,
                                  Type = IqType.result,
                                  Weather = new Weather {Temperature = temp, Humidity = humidity}
                              };
                // send the response
                xmppClient.Send(wiq);
            }
        }
Example #39
0
 void DiscoInfoResult(object sender, IqEventArgs e)
 {
     var query = e.Iq.Element<Info>();
     if (query != null)
     {
         foreach (var id in query.GetIdentities())
         {
             if (id.Category == "pubsub")
             {
                 cboService.Items.Add(e.Iq.From);
                 var newnode = new DiscoNode(e.Iq.From, null, e.Iq.From);
                 treeNodes.Nodes.Add(newnode);
                 DiscoPubSubNodes(e.Iq.From, null, newnode);
             }
         }
     }
 }
Example #40
0
 private void DeleteNodeResult(object sender, IqEventArgs e)
 {
     if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
      {
          var pNode = e.State as DiscoNode;
          if (pNode != null)
          {
              MessageBox.Show(String.Format("node {0} was deleted!", pNode.Node));
              pNode.Remove();
          }
      }
      else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
      {
          // handle error here.
      }
 }
Example #41
0
        void DiscoItemsResult(object sender, IqEventArgs e)
        {
            //<iq from="vm-debian" to="alex@vm-debian/MatriX" id="MX_4" type="result" xmlns="jabber:client">
            //  <query xmlns="http://jabber.org/protocol/disco#items">
            //      <item jid="conference.vm-debian" />
            //      <item jid="irc.vm-debian" />
            //      <item jid="pubsub.vm-debian" />
            //      <item jid="vjud.vm-debian" />
            //  </query>
            //</iq>

            var query = e.Iq.Element<Matrix.Xmpp.Disco.Items>();
            if (query != null)
            {
                foreach (var itm in query.GetItems())
                {
                    // some servers have problems ifwe flood them weith too many packets here
                    // the sleep is a hack to avpid this problems.
                    //System.Threading.Thread.Sleep(200);
                    //_dm.DiscoverInformation(itm.Jid, itm.Node);
                    _dm.DiscoverInformation(itm.Jid, itm.Node, new EventHandler<IqEventArgs>(DiscoInfoResult));
                }
            }
        }
Example #42
0
 void DiscoPubSubNodesResult(object sender, IqEventArgs e)
 {
     /*
     <iq from="pubsub.vm-debian" type="result" to="alex@vm-debian/Alex-TP" id="aadda" >
         <query xmlns="http://jabber.org/protocol/disco#items" node="/home" >
             <item node="/home/vm-debian" name="vm-debian" jid="pubsub.vm-debian" />
         </query>
     </iq>
     */
     var query = e.Iq.Element<Matrix.Xmpp.Disco.Items>();
     if (query != null)
     {
         foreach (var item in query.GetItems())
         {
             var newnode = new DiscoNode(item.Name, item.Node, item.Jid)
                               {ContextMenuStrip = contextMenuStripNodes};
             ((TreeNode) e.State).Nodes.Add(newnode);
             DiscoPubSubNodes(item.Jid, item.Node, newnode);
         }
     }
 }
Example #43
0
        private void PublishResult(object sender, IqEventArgs e)
        {
            if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
            {

            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
            {
                // handle error here.
            }
        }
Example #44
0
 private void xmppClient_OnIq(object sender, IqEventArgs e)
 {
     DisplayEvent("OnIq");
 }
Example #45
0
 void client_OnIq(object sender, IqEventArgs e)
 {
     Console.WriteLine("{0} iq:{1}", m_Name, e.Iq);
 }
Example #46
0
        private void VcardResponse(object sender, IqEventArgs e)
        {
            if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
            {
                var vc = e.Iq.Query as Vcard;
                UserName = vc.Fullname;

                if (!Util.ChatForms.ContainsKey(Group.Name))
                {
                    var roomJid = new Jid(Group.Name);
                    var f = new FrmGroupChat(xmppClient, roomJid, UserName, listContacts);
                    f.MdiParent = FrmParent.Instance;
                    f.Show();
                }
            }
        }
Example #47
0
        private void WeatherInfoResponse(object sender, IqEventArgs e)
        {
            var iq = e.Iq;

            if (iq.Type == IqType.result)
            {
                var weather = iq.Element<Weather>();
                if (weather != null)
                {
                    var zip = e.State as string;

                    MessageBox.Show(String.Format("weather info for zip code: {0}\r\n\r\nHumidity: {1}\r\nTemperature: {2}",
                                                  zip, weather.Humidity, weather.Temperature));
                }
            }
            else if (iq.Type == IqType.error)
            {
                // process errors here
            }
        }
Example #48
0
 private void OnRegisterError(object sender, IqEventArgs iqEventArgs)
 {
     
 }
Example #49
0
 void xmppClient_OnIq(object sender, IqEventArgs e)
 {
     DisplayEvent("OnIq");
     DisplayEvent(String.Format("   ==> From:{0}", e.Iq.From));
 }
Example #50
0
        private void OnPubSubDeleteNode(object sender, IqEventArgs e)
        {
            var pubsub = e.Iq.Element<Matrix.Xmpp.PubSub.PubSub>();
            var error = e.Iq.Element<Error>();

            if (e.Iq.Type == Matrix.Xmpp.IqType.result)
            {
                Debug.WriteLine("node [" + m_node + "] is deleted!");
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
            {
                Debug.WriteLine("creation of node [{0}] failed!\r\nError Condition: {1}\r\nError Type: {2}", m_node, error.Condition, error.Type);
            }
        }
Example #51
0
        // Invoked just after the creation (or retrieving) the node.
        // If newly created or already exists, then subscribe (or other operations) can be carried out.
        // otherwise, no-op.
        private void OnPubSubCreateNode(object sender, IqEventArgs e)
        {
            m_bCreated = false;
            var error = e.Iq.Element<Error>();

            if (e.Iq.Type == Matrix.Xmpp.IqType.result)
            {
                Debug.WriteLine("node is created!");
                m_bCreated = true;
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
            {
                if (error != null)
                {
                    if (error.Condition == Matrix.Xmpp.Base.ErrorCondition.Conflict)
                    {
                        Debug.WriteLine("Node is already exist!");
                        m_bCreated = true;
                    }
                    else
                    {
                        Debug.WriteLine("creation of node failed!\r\nError Condition: {0}\r\nError Type: {1}", error.Condition, error.Type);
                    }
                }
            }
        }
Example #52
0
        private void CreateNodeResult(object sender, IqEventArgs e)
        {
            /*
            <iq from="pubsub.vm-debian" to="alex@vm-debian/MatriX" id="MX_9" type="result" xmlns="jabber:client">
                <pubsub xmlns="http://jabber.org/protocol/pubsub">
                    <create node="/home/vm-debian/alex" />
                </pubsub>
            </iq>
            */
            if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
            {
                var pubsub = e.Iq.Element<PubSub>();
                if (pubsub != null)
                {
                    if (pubsub.Create != null)
                        MessageBox.Show(String.Format("node {0} was created!", pubsub.Create.Node));
                }
            }
            else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
            {
                string node = "";

                var error = e.Iq.Element<Error>();
                var pubsub = e.Iq.Element<PubSub>();
                if (pubsub != null)
                {
                    if (pubsub.Create != null)
                        node = pubsub.Create.Node;
                }

                if (error != null)
                {

                    string msg = String.Format("creation of node {0} failed!\r\nError Condition: {1}\r\nError Type: {2}",
                                               node,
                                               error.Condition,
                                               error.Type);
                    MessageBox.Show(msg);
                }
            }
        }
Example #53
0
 private void VcardUpdateResponse(object sender, IqEventArgs e)
 {
     if (e.Iq.Type == Matrix.Xmpp.IqType.result)
     {
         MessageBox.Show("The VCard was updated successful!!");
     }
 }