コード例 #1
0
        private void StartEventProcessing()
        {
            try
            {
                // This socket is to listen for the events from SIP Servers.
                m_udpEventListener = new UdpClient(m_eventListenerPort, AddressFamily.InterNetwork);

                // Wait for events from the SIP Server agents and when received pass them onto the client connections for processing and dispatching.
                IPEndPoint remoteEP = null;
                while (m_listenForEvents)
                {
                    byte[] buffer = m_udpEventListener.Receive(ref remoteEP);

                    if (buffer != null && buffer.Length > 0)
                    {
                        //logger.Debug("Monitor event received: " + Encoding.ASCII.GetString(buffer, 0, buffer.Length) + ".");
                        SIPMonitorEvent sipMonitorEvent = SIPMonitorEvent.ParseEventCSV(Encoding.ASCII.GetString(buffer, 0, buffer.Length));

                        if (sipMonitorEvent != null)
                        {
                            m_clientManager.MonitorEventReceived(sipMonitorEvent);
                        }
                    }
                }

                m_udpEventListener.Close();
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPMonitorMediator StartEventProcessing. " + excp.Message);
            }
        }
コード例 #2
0
        private void NotificationReady(string addressID)
        {
            try
            {
                if (addressID == m_notificationsAddress)
                {
                    string        sessionID     = null;
                    string        sessionError  = null;
                    List <string> notifications = m_publisher.GetNotifications(m_notificationsAddress, out sessionID, out sessionError);

                    if (sessionError != null)
                    {
                        logger.Warn("SIPSorceryVT100Server error on get notifications. " + sessionError + ".");
                    }
                    else if (m_notificationsSessionID == sessionID)
                    {
                        foreach (string notification in notifications)
                        {
                            MonitorEventAvailable(SIPMonitorEvent.ParseEventCSV(notification));
                        }
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPSorceryVT100Server NotificationReady. " + excp.Message);
            }
        }
コード例 #3
0
        private void Listen()
        {
            try
            {
                Thread.CurrentThread.Name = UDP_LISTENER_THREAD_NAME;

                UdpClient udpClient = new UdpClient(m_eventReceiverEndPoint);

                byte[] buffer = null;

                logger.Debug("SIPMonitorUDPSink socket on " + m_eventReceiverEndPoint.ToString() + " listening started.");

                while (!Exit)
                {
                    IPEndPoint inEndPoint = new IPEndPoint(IPAddress.Any, 0);

                    try
                    {
                        buffer = udpClient.Receive(ref inEndPoint);
                    }
                    catch (SocketException)
                    {
                        continue;
                    }
                    catch (Exception listenExcp)
                    {
                        // There is no point logging this as without processing the ICMP message it's not possible to know which socket the rejection came from.
                        logger.Error("Exception listening on SIPMonitorUDPSink. " + listenExcp.Message);

                        inEndPoint = new IPEndPoint(IPAddress.Any, 0);
                        continue;
                    }

                    if (buffer != null && buffer.Length > 0)
                    {
                        if (MonitorEventReady != null)
                        {
                            SIPMonitorEvent monitorEvent = SIPMonitorEvent.ParseEventCSV(Encoding.UTF8.GetString(buffer));
                            MonitorEventReady(monitorEvent);
                        }
                    }
                }

                logger.Debug("SIPMonitorUDPSink socket on " + m_eventReceiverEndPoint + " listening halted.");
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPMonitorUDPSink Listen. " + excp.Message);
                //throw excp;
            }
        }