示例#1
0
        /// <inheritdoc/>
        public void Send(byte[] data, ISession session, System.Net.EndPoint ep)
        {
            TLSSession tcpSession;

            try {
                if (session == null)
                {
                    IPEndPoint ipEP = (IPEndPoint)ep;

                    TLSSession sessionX = FindSession(ipEP);
                    if (session == null)
                    {
                        sessionX = new TLSSession(ipEP, new QueueItem(null, data), null);
                        sessionX.DataReceived += this.DataReceived;

                        sessionX.Connect();
                        AddSession(sessionX);
                    }
                    session = sessionX;
                }

                tcpSession = session as TLSSession;
                tcpSession.Queue.Enqueue(new QueueItem(tcpSession, data));
                tcpSession.WriteData();
            }
            catch (Exception e) {
                Console.WriteLine("Error in TLS Sending - " + e.ToString());
            }
        }
示例#2
0
        /// <inheritdoc/>
        public ISession GetSession(System.Net.EndPoint ep)
        {
            IPEndPoint ipEP = (IPEndPoint)ep;

            TLSSession sessionX = FindSession(ipEP);

            return(sessionX);
        }
示例#3
0
文件: TLSSession.cs 项目: jimsch/TCP
        private static void ReadCallback(IAsyncResult ar)
        {
            try {
                TLSSession session = (TLSSession)ar.AsyncState;

                int cbRead = session._stm.EndRead(ar);
                session.ProcessInput(cbRead);
            }
            catch (ObjectDisposedException) {
                ; // Ignore this error
            }
        }
示例#4
0
文件: TLSChannel.cs 项目: jimsch/TCP
        private void DoAccept(TcpClient tcpClient)
        {
            TLSSession session = new TLSSession(tcpClient, _clientKeys, _signingKeys);

            AddSession(session);
            StartAccepts();

            session.DataReceived += this.DataReceived;
            session.Accept();

            session.BeginRead();
            session.SendCSMSignal();
        }
示例#5
0
        private static void ReadCallback(IAsyncResult ar)
        {
            try {
                TLSSession session = (TLSSession)ar.AsyncState;

                int cbRead = session._tcpStream.EndRead(ar);
                session.ProcessInput(cbRead);
            }
            catch (System.IO.IOException) {
                ; // Ignore this error - but I don't know if that is correct.
            }
            catch (ObjectDisposedException) {
                ; // Ignore this error
            }
        }
示例#6
0
        private void FireDataReceived(Byte[] data, System.Net.EndPoint ep, System.Net.EndPoint epLocal, TLSSession tcpSession)
        {
            EventHandler <DataReceivedEventArgs> h = DataReceived;

            if (h != null)
            {
                h(this, new DataReceivedEventArgs(data, ep, epLocal, tcpSession));
            }
        }
示例#7
0
 private static void AddSession(TLSSession session)
 {
     lock (_sessionList) {
         _sessionList.Add(session);
     }
 }