/// <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()); } }
/// <inheritdoc/> public ISession GetSession(System.Net.EndPoint ep) { IPEndPoint ipEP = (IPEndPoint)ep; TLSSession sessionX = FindSession(ipEP); return(sessionX); }
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 } }
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(); }
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 } }
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)); } }
private static void AddSession(TLSSession session) { lock (_sessionList) { _sessionList.Add(session); } }