Esempio n. 1
0
        private XmlElement InitiateStream(string hostname)
        {
            CommonConfig.Logger.WriteInfo("InitiateStream,Hostname:" + hostname);
            XmlElement e = Xml.Element("stream:stream", "jabber:client").Attr("to", hostname).Attr("version", "1.0").Attr("xmlns:stream", "http://etherx.jabber.org/streams").Attr("xml:lang", CultureInfo.CurrentCulture.Name);

            this.Send(e.ToXmlString(true, true));
            CommonConfig.Logger.WriteInfo("Send完成!");
            if (this.parser != null)
            {
                CommonConfig.Logger.WriteInfo("this.parser.Close()!");
                this.parser.Close();
                CommonConfig.Logger.WriteInfo("this.parser.Close()完成!");
            }
            CommonConfig.Logger.WriteInfo("StreamParser开始!");
            this.parser = new StreamParser(this.stream, true);
            CommonConfig.Logger.WriteInfo("StreamParser结束!");
            this.Language = this.parser.Language ?? new CultureInfo("en");
            return(this.parser.NextElement(new string[] { "stream:features" }));
        }
Esempio n. 2
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         this.disposed = true;
         if (disposing)
         {
             if (this.parser != null)
             {
                 this.parser.Close();
             }
             this.parser = null;
             if (this.client != null)
             {
                 this.client.Close();
             }
             this.client = null;
         }
     }
 }
Esempio n. 3
0
		/// <summary>
		/// Initiates an XML stream with the specified entity.
		/// </summary>
		/// <param name="hostname">The name of the receiving entity with which to
		/// initiate an XML stream.</param>
		/// <returns>The 'stream:features' XML element as received from the
		/// receiving entity upon stream establishment.</returns>
		/// <exception cref="XmlException">The XML parser has encountered invalid
		/// or unexpected XML data.</exception>
		/// <exception cref="CultureNotFoundException">The culture specified by the
		/// XML-stream in it's 'xml:lang' attribute could not be found.</exception>
		/// <exception cref="IOException">There was a failure while writing to the
		/// network, or there was a failure while reading from the network.</exception>
		XmlElement InitiateStream(string hostname) {
			var xml = Xml.Element("stream:stream", "jabber:client")
				.Attr("to", hostname)
				.Attr("version", "1.0")
				.Attr("xmlns:stream", "http://etherx.jabber.org/streams")
				.Attr("xml:lang", CultureInfo.CurrentCulture.Name);
			Send(xml.ToXmlString(xmlDeclaration: true, leaveOpen: true));
			// Create a new parser instance.
			if (parser != null)
				parser.Close();
			parser = new StreamParser(stream, true);
			// Remember the default language of the stream. The server is required to
			// include this, but we make sure nonetheless.
			Language = parser.Language ?? new CultureInfo("en");
			// The first element of the stream must be <stream:features>.
			return parser.NextElement("stream:features");
		}
Esempio n. 4
0
		/// <summary>
		/// Releases all resources used by the current instance of the XmppCore
		/// class, optionally disposing of managed resource.
		/// </summary>
		/// <param name="disposing">true to dispose of managed resources, otherwise
		/// false.</param>
		protected virtual void Dispose(bool disposing) {
			if (!disposed) {
				// Indicate that the instance has been disposed.
				disposed = true;
				// Get rid of managed resources.
				if (disposing) {
					if (parser != null)
						parser.Close();
					parser = null;
					if (client != null)
						client.Close();
					client = null;
				}
				// Get rid of unmanaged resources.
			}
		}