Exemplo n.º 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());
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public ISession GetSession(System.Net.EndPoint ep)
        {
            IPEndPoint ipEP = (IPEndPoint)ep;

            TLSSession sessionX = FindSession(ipEP);

            return(sessionX);
        }
Exemplo n.º 3
0
        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
            }
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 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
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 7
0
 private static void AddSession(TLSSession session)
 {
     lock (_sessionList) {
         _sessionList.Add(session);
     }
 }