Inheritance: Stream, IDisposable, IConnectionTimeouts
Ejemplo n.º 1
0
        public StompClient(string aTargetHost, [DefaultParameterValue(0xf0ad)] int aPort, string aUsername, string aPassword)
        {
            this.fSBuilder = new StringBuilder();
            this.fBuilder = new MemoryStream();
            this.fByteReader = new byte[1];

            fSocket = new Connection(new Binding());
            var lEntry = System.Net.Dns.GetHostEntry(aTargetHost);

            for (int i = 0; i < lEntry.AddressList.Length; i++)
            {
                var lIP = lEntry.AddressList[i];
                try
                {
                    fSocket.Connect(lIP, aPort);

                    break;
                }
                catch { }
            }
            if (!fSocket.Connected) throw new ArgumentException("No such host");

            Send("CONNECT", new StringPair[] { new StringPair("login", aUsername), new StringPair("passcode", aPassword) }, null);
            string lResp;
            IList<StringPair> lHeaders;
            byte[] lBody;

            Receive(out lResp, out lHeaders, out lBody);
            if (lResp != "CONNECTED") throw new ArgumentException("Could not login: "******"session").Select(a => a.Value).FirstOrDefault();
        }
Ejemplo n.º 2
0
		protected virtual void TriggerOnTcpConnection(Connection connection)
		{
			if (this.OnTcpConnection != null)
			{
				OnTcpConnectionArgs lEventArgs = new OnTcpConnectionArgs(connection);
				this.OnTcpConnection(this, lEventArgs);
			}
		}
Ejemplo n.º 3
0
		public SslConnection(SslConnectionFactory factory, Connection connection)
			: base((Socket)null)
		{
			this.fFactory = factory;
			this.fInnerConnection = connection;
			this.fInnerConnection.BufferedAsync = false;
			this.fInnerConnection.AsyncDisconnect += InnerConnection_AsyncDisconnect;
			this.fInnerConnection.AsyncHaveIncompleteData += InnerConnection_AsyncHaveIncompleteData;
		}
Ejemplo n.º 4
0
 public BoundIncomingStream(Connection connection, Int32 size)
 {
     this.fConnection = connection;
     this.fSize = size;
     this.fDataLeft = size;
 }
Ejemplo n.º 5
0
 public void Dispose()
 {
     this.Send("DISCONNECT", null, null);
     if (this.fSocket is IDisposable)
     {
         this.fSocket.Dispose();
     }
     this.fSocket = null;
 }
Ejemplo n.º 6
0
		public OnTcpConnectionArgs(Connection connection)
			: base(connection)
		{
		}
Ejemplo n.º 7
0
		internal protected virtual void HandleTcpConnection(Connection connection)
		{
			this.TriggerOnTcpConnection(connection);
		}
		public virtual Connection CreateClientConnection(Connection connection)
		{
			if (this.IsCertificateLoadPending)
			{
				this.LoadCertificate();
			}

			return new SslConnection(this, connection);
		}
Ejemplo n.º 9
0
		public ConnectionEventArgs(Connection connection)
			: base()
		{
			this.fConnection = connection;
		}
Ejemplo n.º 10
0
 public SslConnection(SslConnectionFactory factory, Connection connection)
     : base((Socket)null)
 {
     fFactory = factory;
     fInnerConnection = connection;
     fInnerConnection.BufferedAsync = false;
     fInnerConnection.AsyncDisconnect += new EventHandler(InnerConnection_AsyncDisconnect);
     fInnerConnection.AsyncHaveIncompleteData += new EventHandler(InnerConnection_AsyncHaveIncompleteData);
 }
Ejemplo n.º 11
0
        public virtual Connection CreateClientConnection(Connection connection)
        {
            if (this.HasCertificate)
                this.LoadCertificate();

            return new SslConnection(this, connection);
        }