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

            TLSSession sessionX = FindSession(ipEP);

            return(sessionX);
        }
Exemple #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
            }
        }
Exemple #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();
        }
Exemple #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
            }
        }
Exemple #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));
            }
        }
Exemple #7
0
 private static void AddSession(TLSSession session)
 {
     lock (_sessionList) {
         _sessionList.Add(session);
     }
 }