コード例 #1
0
ファイル: UserTune.cs プロジェクト: luz-sf/Net.Xmpp
        /// <summary>
        /// Invoked when a contact has published music information.
        /// </summary>
        /// <param name="jid">The JID of the XMPP entity that published the tune
        /// information.</param>
        /// <param name="item">The 'item' Xml element of the pubsub publish
        /// event.</param>
        private void onTune(Jid jid, XmlElement item)
        {
            if (item == null || item["tune"] == null)
            {
                return;
            }
            var tune = item["tune"];

            if (tune.IsEmpty)
            {
                // Raise the 'Tune' event without information.
                Tune.Raise(this, new TuneEventArgs(jid));
                return;
            }
            // Parse 'tune' element.
            int length = 0;

            if (tune["length"] != null)
            {
                length = int.Parse(tune["length"].InnerText);
            }
            int rating = 0;

            if (tune["rating"] != null)
            {
                rating = int.Parse(tune["rating"].InnerText);
            }
            TuneInformation info = new TuneInformation(
                GetField(tune, "title"), GetField(tune, "artist"), GetField(tune, "track"),
                length, rating, GetField(tune, "source"), GetField(tune, "uri"));

            // Raise the 'Tune' event.
            Tune.Raise(this, new TuneEventArgs(jid, info));
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the TuneEventArgs class.
 /// </summary>
 /// <param name="jid">The JID of the XMPP entity that published the
 /// tune information.</param>
 /// <param name="information">The tune information to include as part of
 /// the event.</param>
 /// <exception cref="ArgumentNullException">The jid parameter is
 /// null.</exception>
 public TuneEventArgs(Jid jid, TuneInformation information = null)
 {
     jid.ThrowIfNull("jid");
     Jid         = jid;
     Information = information;
 }
コード例 #3
0
ファイル: UserTune.cs プロジェクト: luz-sf/Net.Xmpp
 /// <summary>
 /// Publishes the specified music information to contacts on the user's
 /// roster.
 /// </summary>
 /// <param name="tune">The tune information to publish.</param>
 /// <exception cref="ArgumentNullException">The tune parameter is
 /// null.</exception>
 /// <exception cref="NotSupportedException">The server does not support the
 /// 'Personal Eventing Protocol' extension.</exception>
 /// <exception cref="XmppErrorException">The server returned an XMPP error code.
 /// Use the Error property of the XmppErrorException to obtain the specific
 /// error condition.</exception>
 /// <exception cref="XmppException">The server returned invalid data or another
 /// unspecified XMPP error occurred.</exception>
 /// <remarks>Publishing no information (i.e. calling Publish without any parameters
 /// is considered a "stop command" to disable publishing).</remarks>
 public void Publish(TuneInformation tune)
 {
     tune.ThrowIfNull("tune");
     Publish(tune.Title, tune.Artist, tune.Track, tune.Length,
             tune.Rating, tune.Source, tune.Uri);
 }