コード例 #1
0
ファイル: UserTune.cs プロジェクト: Krivda/gUmMY
        /// <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
ファイル: XmppClient.cs プロジェクト: REPLDigital/Sharp.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>
 /// <exception cref="InvalidOperationException">The XmppClient instance is not
 /// connected to a remote host, or the XmppClient instance has not authenticated with
 /// the XMPP server.</exception>
 /// <exception cref="ObjectDisposedException">The XmppClient object has been
 /// disposed.</exception>
 /// <include file='Examples.xml' path='S22/Xmpp/Client/XmppClient[@name="SetTune"]/*'/>
 public void SetTune(TuneInformation tune)
 {
     AssertValid();
     userTune.Publish(tune);
 }
コード例 #3
0
ファイル: TuneEventArgs.cs プロジェクト: Krivda/gUmMY
 /// <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;
 }
コード例 #4
0
ファイル: TuneEventArgs.cs プロジェクト: rafaneri/Sharp.Xmpp
		/// <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;
		}
コード例 #5
0
ファイル: UserTune.cs プロジェクト: Krivda/gUmMY
 /// <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);
 }
コード例 #6
0
ファイル: UserTune.cs プロジェクト: REPLDigital/Sharp.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 = Int32.Parse(tune["length"].InnerText);
     int rating = 0;
     if (tune["rating"] != null)
         rating = Int32.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));
 }
コード例 #7
0
ファイル: UserTune.cs プロジェクト: REPLDigital/Sharp.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);
 }
コード例 #8
0
 /// <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 async Task Publish(TuneInformation tune)
 {
     tune.ThrowIfNull("tune");
     await Publish(tune.Title, tune.Artist, tune.Track, tune.Length,
                   tune.Rating, tune.Source, tune.Uri);
 }