Пример #1
0
        private void publishToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var payload = InputBox("Enter the payload to publish!", "Payload", "");

            if (payload == string.Empty)
            {
                return;
            }

            var item = new Matrix.Xmpp.PubSub.Item {
                Value = payload
            };

            //var item = new Matrix.Xmpp.PubSub.Item();
            //item.Add(new XmppXElement("mypaload", "mynamespace"));

            var pNode = treeNodes.SelectedNode as DiscoNode;

            if (pNode != null)
            {
                _pm.PublishItem(cboService.Text,
                                pNode.Node,
                                item,
                                PublishResult);
            }
        }
Пример #2
0
        public void TestPublishItem()
        {
            const string XML = @"<iq type='set'            
            to='pubsub.shakespeare.lit'
            id='publish1'
            xmlns='jabber:client'>
          <pubsub xmlns='http://jabber.org/protocol/pubsub'>
            <publish node='princely_musings'>
              <item>
                <entry xmlns='http://www.w3.org/2005/Atom'>
                  <title>Soliloquy</title>
                  <summary>
        To be, or not to be: that is the question:
        Whether 'tis nobler in the mind to suffer
        The slings and arrows of outrageous fortune,
        Or to take arms against a sea of troubles,
        And by opposing end them?
                  </summary>
                  <link rel='alternate' type='text/html'
                        href='http://denmark.lit/2003/12/13/atom03'/>
                  <id>tag:denmark.lit,2003:entry-32397</id>
                  <published>2003-12-13T18:30:02Z</published>
                  <updated>2003-12-13T18:30:02Z</updated>
                </entry>
              </item>
            </publish>
          </pubsub>
        </iq>";

            const string PAYLOAD1 =
                @"<entry xmlns='http://www.w3.org/2005/Atom'>
                  <title>Soliloquy</title>
                  <summary>
        To be, or not to be: that is the question:
        Whether 'tis nobler in the mind to suffer
        The slings and arrows of outrageous fortune,
        Or to take arms against a sea of troubles,
        And by opposing end them?
                  </summary>
                  <link rel='alternate' type='text/html'
                        href='http://denmark.lit/2003/12/13/atom03'/>
                  <id>tag:denmark.lit,2003:entry-32397</id>
                  <published>2003-12-13T18:30:02Z</published>
                  <updated>2003-12-13T18:30:02Z</updated>
                </entry>";

            var payload = XmppXElement.LoadXml(PAYLOAD1);

            var item = new Item();

            item.Add(payload);

            Iq iq = PubSubBuilder.PublishItems("pubsub.shakespeare.lit", "princely_musings", new[] { item });

            iq.Id = "publish1";

            iq.ShouldBe(XML);
        }
Пример #3
0
 public void Publish(JsonReading jr)
 {
     if (m_bReady == true)
     {
         var item = new Matrix.Xmpp.PubSub.Item();
         item.Add(new SensorPayload {
             Value = jr.JsonObjCollection.ToString()
         });
         m_psMgr.PublishItem(m_psJid, m_node, item);
         //Debug.WriteLine("item published" + jr.JsonObjCollection.ToString());
     }
 }
Пример #4
0
 public void Publish(JsonReading jr)
 {
     if (m_bReady == true)
     {
         var item = new Matrix.Xmpp.PubSub.Item();
         item.Add(new SensorPayload { Value = jr.JsonObjCollection.ToString() });
         m_psMgr.PublishItem(m_psJid, m_node, item);
         //Debug.WriteLine("item published" + jr.JsonObjCollection.ToString());
     }
 }
Пример #5
0
        private void publishToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var payload = InputBox("Enter the payload to publish!", "Payload", "");

            if (payload == string.Empty)
                return;

            var item = new Matrix.Xmpp.PubSub.Item {Value = payload};

            //var item = new Matrix.Xmpp.PubSub.Item();
            //item.Add(new XmppXElement("mypaload", "mynamespace"));

            var pNode = treeNodes.SelectedNode as DiscoNode;
            if (pNode != null)
            {
                _pm.PublishItem(cboService.Text,
                                pNode.Node,
                                item,
                                PublishResult);
            }
        }
Пример #6
0
 /// <summary>
 /// Publishes an item to a node.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="item">The item.</param>
 /// <param name="timeout">The timeout in milliseconds.</param>
 /// <param name="cancellationToken">The cancellation token used to cancel the request.</param>
 /// <returns></returns>
 public static async Task <Iq> PublishItemAsync(
     this IClientIqSender iqSender, Jid to, string node, Item item, int timeout, CancellationToken cancellationToken)
 {
     return(await PublishItemsAsync(iqSender, to, node, new[] { item }, timeout, cancellationToken));
 }
Пример #7
0
 /// <summary>
 /// Publishes an item to a node.
 /// </summary>
 /// <param name="iqSender">The <see cref="IClientIqSender"/></param>
 /// <param name="to">To.</param>
 /// <param name="node">The node.</param>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public static async Task <Iq> PublishItemAsync(this IClientIqSender iqSender, Jid to, string node, Item item)
 {
     return(await PublishItemsAsync(iqSender, to, node, new[] { item }, DefaultTimeout, CancellationToken.None));
 }