상속: Stream, IDisposable, IConnectionTimeouts
예제 #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();
        }
예제 #2
0
		protected virtual void TriggerOnTcpConnection(Connection connection)
		{
			if (this.OnTcpConnection != null)
			{
				OnTcpConnectionArgs lEventArgs = new OnTcpConnectionArgs(connection);
				this.OnTcpConnection(this, lEventArgs);
			}
		}
예제 #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;
		}
예제 #4
0
 public BoundIncomingStream(Connection connection, Int32 size)
 {
     this.fConnection = connection;
     this.fSize = size;
     this.fDataLeft = size;
 }
예제 #5
0
 public void Dispose()
 {
     this.Send("DISCONNECT", null, null);
     if (this.fSocket is IDisposable)
     {
         this.fSocket.Dispose();
     }
     this.fSocket = null;
 }
예제 #6
0
		public OnTcpConnectionArgs(Connection connection)
			: base(connection)
		{
		}
예제 #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);
		}
		public ConnectionEventArgs(Connection connection)
			: base()
		{
			this.fConnection = connection;
		}
예제 #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);
 }
예제 #11
0
        public virtual Connection CreateClientConnection(Connection connection)
        {
            if (this.HasCertificate)
                this.LoadCertificate();

            return new SslConnection(this, connection);
        }