コード例 #1
0
ファイル: UserTune.cs プロジェクト: lcmxiaoya/xmpp-source
 private void onTune(Jid jid, XmlElement item)
 {
     if ((item != null) && (item["tune"] != null))
     {
         XmlElement tune = item["tune"];
         if (tune.IsEmpty)
         {
             this.Tune.Raise <TuneEventArgs>(this, new TuneEventArgs(jid, null));
         }
         else
         {
             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 information = new TuneInformation(this.GetField(tune, "title"), this.GetField(tune, "artist"), this.GetField(tune, "track"), length, rating, this.GetField(tune, "source"), this.GetField(tune, "uri"));
             this.Tune.Raise <TuneEventArgs>(this, new TuneEventArgs(jid, information));
         }
     }
 }
コード例 #2
0
ファイル: UserTune.cs プロジェクト: timaxoxa/S22.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>
        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));
        }
コード例 #3
0
ファイル: UserTune.cs プロジェクト: BlueBasher/S22.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>
		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));
		}
コード例 #4
0
ファイル: UserTune.cs プロジェクト: BlueBasher/S22.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);
		}
コード例 #5
0
ファイル: UserTune.cs プロジェクト: lcmxiaoya/xmpp-source
 public void Publish(TuneInformation tune)
 {
     tune.ThrowIfNull <TuneInformation>("tune");
     this.Publish(tune.Title, tune.Artist, tune.Track, tune.Length, tune.Rating, tune.Source, tune.Uri);
 }
コード例 #6
0
ファイル: XmppClient.cs プロジェクト: BlueBasher/S22.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);
		}
コード例 #7
0
ファイル: TuneEventArgs.cs プロジェクト: BlueBasher/S22.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;
		}
コード例 #8
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;
 }
コード例 #9
0
 public TuneEventArgs(S22.Xmpp.Jid jid, TuneInformation information = null)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid         = jid;
     this.Information = information;
 }