Example #1
0
        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);
        }
Example #2
0
        protected virtual void OnSipReceivedFromTcp(SipMessageEventArgs e)
        {
            if (null != SipReceivedFromPipe)
            {
                SipReceivedFromPipe(this, e);
            }

            if (!e.Cancel && e.SipMessage.StartsWith("BYE", StringComparison.InvariantCultureIgnoreCase))
            {             // We should kill sound proxy
                REGEX.Match m = g_CallId.Match(e.SipMessage);
                if (m.Success && m.Groups["q"].Success)
                {
                    string     callId = m.Groups["q"].Value;
                    SoundProxy sp     = null;
                    if (m_SoundProxies.TryGetValue(callId, out sp))
                    {
                        m_SoundProxies.Remove(callId);
                        sp.Dispose();
                        m_Settings.WriteMessageToLog(
                            LogMessageType.Information + 1,
                            "Destroyed sound proxy for Call-ID '" + callId + '\''
                            );
                    }
                }
            }
        }
Example #3
0
        public ServerListener(ProgramSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException("settings");
            }
            if (0 == settings.ServerPort)
            {
                throw new ApplicationException();
            }

            m_Settings = settings;

            m_tcpListener = new SOCK.TcpListener(
                new NET.IPEndPoint(NET.IPAddress.Any, settings.ServerPort)
                );
            m_tcpListener.Start();
            m_tcpListener.BeginAcceptTcpClient(OnConnect, null);

            m_Settings.WriteMessageToLog(
                LogMessageType.Information,
                string.Format(CultureInfo.CurrentUICulture, "SipTunnel server started and is listening on port {0}.", m_Settings.ServerPort)
                );
        }