private void OnConnect(IAsyncResult ar) { SOCK.TcpClient newClient = null; try { newClient = m_tcpListener.EndAcceptTcpClient(ar); } catch (Exception) { } if (null != newClient) { System.Net.IPEndPoint newEp = (System.Net.IPEndPoint)newClient.Client.RemoteEndPoint; m_Settings.WriteMessageToLog( LogMessageType.Information + 1, string.Format(CultureInfo.CurrentUICulture, "Client {0}:{1} connected.", newEp.Address, newEp.Port) ); SipProxyServer sps = new SipProxyServer(newClient, m_Settings); sps.PipeDead += Proxy_PipeDead; m_ClientConnections.Add(newEp, sps); } m_tcpListener.BeginAcceptTcpClient(OnConnect, null); }
void Proxy_PipeDead(object sender, EventArgs e) { SipProxyServer sps = (SipProxyServer)sender; bool removed = m_ClientConnections.Remove(sps.PipeRemoteEndPoint); if (removed) { sps.Dispose(); m_Settings.WriteMessageToLog( LogMessageType.Information, string.Format( CultureInfo.InstalledUICulture, "Removed server SipProxy for {0}:{1}.", sps.PipeRemoteEndPoint.Address, sps.PipeRemoteEndPoint.Port ) ); } }