/// <summary> /// Server TCP,TLS constructor. /// </summary> /// <param name="stack">Owner stack.</param> /// <param name="session">TCP session.</param> /// <exception cref="ArgumentNullException">Is raised when <b>stack</b> or <b>session</b> is null reference.</exception> internal SIP_Flow(SIP_Stack stack,TCP_Session session) { if(stack == null){ throw new ArgumentNullException("stack"); } if(session == null){ throw new ArgumentNullException("session"); } m_pStack = stack; m_pTcpSession = session; m_IsServer = true; m_pLocalEP = session.LocalEndPoint; m_pRemoteEP = session.RemoteEndPoint; m_Transport = session.IsSecureConnection ? SIP_Transport.TLS : SIP_Transport.TCP; m_CreateTime = DateTime.Now; m_LastActivity = DateTime.Now; m_ID = m_pLocalEP.ToString() + "-" + m_pRemoteEP.ToString() + "-" + m_Transport; m_pMessage = new MemoryStream(); BeginReadHeader(); }
/// <summary> /// Cleans up any resources being used. /// </summary> public void Dispose() { lock(m_pLock){ if(m_IsDisposed){ return; } OnDisposing(); m_IsDisposed = true; if(m_pTcpSession != null){ m_pTcpSession.Dispose(); m_pTcpSession = null; } m_pMessage = null; if(m_pKeepAliveTimer != null){ m_pKeepAliveTimer.Dispose(); m_pKeepAliveTimer = null; } } }
public client_object(TCP_Session t) { target = t; begin_read_server(); }
/// <summary> /// Starts flow processing. /// </summary> internal void Start() { // Move processing to thread pool. AutoResetEvent startLock = new AutoResetEvent(false); ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state){ lock(m_pLock){ startLock.Set(); // TCP / TLS client, connect to remote end point. if(!m_IsServer && m_Transport != SIP_Transport.UDP){ try{ TCP_Client client = new TCP_Client(); client.Connect(m_pLocalEP,m_pRemoteEP,m_Transport == SIP_Transport.TLS); m_pTcpSession = client; BeginReadHeader(); } catch{ Dispose(); } } } })); startLock.WaitOne(); startLock.Close(); }