private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent) { try { if (sipMonitorEvent != null && m_monitorEventWriter != null) { if (sipMonitorEvent is SIPMonitorConsoleEvent) { SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent; if (consoleEvent.EventType != SIPMonitorEventTypesEnum.NATKeepAlive) { logger.Debug("re: " + sipMonitorEvent.Message); } m_monitorEventWriter.Send(sipMonitorEvent); } else { m_monitorEventWriter.Send(sipMonitorEvent); } } } catch (Exception excp) { logger.Error("Exception FireSIPMonitorEvent. " + excp.Message); } }
private void FireSIPMonitorLogEvent(SIPMonitorEvent monitorEvent) { //if (SIPMonitorEventLog_External != null) //{ // SIPMonitorEventLog_External(monitorEvent); //} }
private void FireProxyLogEvent(SIPMonitorEvent monitorEvent) { try { m_statefulProxyLogEvent?.Invoke(monitorEvent); } catch (Exception excp) { logger.Error("Exception FireProxyLogEvent ForkCall. " + excp.Message); } }
private void FireProxyLogEvent(SIPMonitorEvent monitorEvent) { if (SIPMonitorLogEvent_External != null) { try { SIPMonitorLogEvent_External(monitorEvent); } catch (Exception excp) { logger.Error("Exception FireProxyLogEvent SIPAppServerCore. " + excp.Message); } } }
private void SendMonitorEventViaUDP(SIPMonitorEvent monitorEvent, string destinationSocket) { try { byte[] monitorEventBytes = Encoding.UTF8.GetBytes(monitorEvent.ToCSV()); m_udpEventSender.Send(monitorEventBytes, monitorEventBytes.Length, IPSocket.ParseSocketString(destinationSocket)); } catch (Exception excp) { logger.Error("Exception SendMonitorEventViaUDP. " + excp.Message); } }
public void SerializeMeassageOnlyProxyEventHeadersTest() { Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); SIPMonitorEvent monitorEvent = new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.FullSIPTrace, "Test", null, null, null, null, SIPCallDirection.None); string serialisedEvent = monitorEvent.ToCSV(); SIPMonitorEvent desMonitorEvent = SIPMonitorConsoleEvent.ParseClientControlEventCSV(serialisedEvent); Assert.AreEqual(monitorEvent.Message, desMonitorEvent.Message, "The event message was not serialised/desrialised correctly."); Assert.AreEqual(monitorEvent.Created.ToString(), desMonitorEvent.Created.ToString(), "The event created was not serialised/desrialised correctly."); }
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; } }
private void FireProxyLogEvent(SIPMonitorEvent monitorEvent) { try { if (LogDelegate_External != null) { LogDelegate_External(monitorEvent); } } catch (Exception excp) { logger.Error("Exception FireProxyLogEvent DialPlanEngine. " + excp.Message); } }
private void FireProxyLogEvent(SIPMonitorEvent monitorEvent) { //if (m_registrarLogEvent != null) //{ // try // { // m_registrarLogEvent(monitorEvent); // } // catch (Exception excp) // { // logger.Error("Exception FireProxyLogEvent RegistrarCore. " + excp.Message); // } //} }
private void FireProxyLogEvent(SIPMonitorEvent monitorEvent) { if (m_registrarLogEvent != null) { try { m_registrarLogEvent(monitorEvent); } catch (Exception excp) { logger.Error("Exception FireProxyLogEvent RegistrarCore. " + excp.Message); } } }
private void FireSIPMonitorLogEvent(SIPMonitorEvent monitorEvent) { if (SIPMonitorLog_External != null) { try { SIPMonitorLog_External(monitorEvent); } catch (Exception excp) { logger.Error("Exception FireProxyLogEvent NATKeepAliveRelay. " + excp.Message); } } }
private static void LogTraceMessage(SIPMonitorEvent monitorEvent) { if (monitorEvent is SIPMonitorConsoleEvent) { SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent; if (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace && consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction && consoleEvent.EventType != SIPMonitorEventTypesEnum.Timing && consoleEvent.EventType != SIPMonitorEventTypesEnum.UnrecognisedMessage && consoleEvent.EventType != SIPMonitorEventTypesEnum.NATKeepAliveRelay && consoleEvent.EventType != SIPMonitorEventTypesEnum.BadSIPMessage) { logger.Debug("Monitor: " + monitorEvent.Message); } } }
private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent) { try { if (sipMonitorEvent != null && m_monitorEventWriter != null) { if (!(sipMonitorEvent is SIPMonitorConsoleEvent && ((SIPMonitorConsoleEvent)sipMonitorEvent).EventType == SIPMonitorEventTypesEnum.SIPTransaction)) { m_monitorEventWriter.Send(sipMonitorEvent); } } } catch (Exception excp) { logger.Error("Exception FireSIPMonitorEvent. " + excp.Message); } }
public bool MonitorEventAvailable(SIPMonitorEvent monitorEvent) { try { SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent; if (consoleEvent != null && consoleEvent.SessionID == m_notificationsSessionID) { OutStream.Write(Encoding.ASCII.GetBytes(consoleEvent.ToConsoleString(AdminId))); OutStream.Flush(); return(true); } return(false); } catch (Exception excp) { logger.Error("Exception SIPSorceryVT100Server NotificationReady. " + excp.Message); return(false); } }
public void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent) { try { if (sipMonitorEvent != null) { if (sipMonitorEvent.GetType() != typeof(SIPMonitorMachineEvent)) { logger.Debug("ra: " + sipMonitorEvent.Message); } if (m_monitorEventWriter != null) { m_monitorEventWriter.Send(sipMonitorEvent); } } } catch (Exception excp) { logger.Error("Exception FireSIPMonitorEvent. " + excp.Message); } }
private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent) { try { if (sipMonitorEvent != null && m_monitorEventWriter != null) { if (sipMonitorEvent is SIPMonitorConsoleEvent) { SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent; if (consoleEvent.ServerType == SIPMonitorServerTypesEnum.RegisterAgent || (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace && consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction && consoleEvent.EventType != SIPMonitorEventTypesEnum.Timing && consoleEvent.EventType != SIPMonitorEventTypesEnum.UnrecognisedMessage && consoleEvent.EventType != SIPMonitorEventTypesEnum.ContactRegisterInProgress && consoleEvent.EventType != SIPMonitorEventTypesEnum.Monitor)) { string eventUsername = (sipMonitorEvent.Username.IsNullOrBlank()) ? null : " " + sipMonitorEvent.Username; dialPlanLogger.Debug("as (" + DateTime.Now.ToString("mm:ss:fff") + eventUsername + "): " + sipMonitorEvent.Message); } if (consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction) { m_monitorEventWriter.Send(sipMonitorEvent); } } else { m_monitorEventWriter.Send(sipMonitorEvent); } } } catch (Exception excp) { logger.Error("Exception FireSIPMonitorEvent. " + excp.Message); } }
private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent) { try { if (sipMonitorEvent != null) { if (sipMonitorEvent is SIPMonitorConsoleEvent) { SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent; logger.Debug("rtcc: " + sipMonitorEvent.Message); } if (m_monitorEventWriter != null) { m_monitorEventWriter.Send(sipMonitorEvent); } } } catch (Exception excp) { logger.Error("Exception FireSIPMonitorEvent. " + excp.Message); } }
private bool MonitorEventAvailable(SIPMonitorEvent sipMonitorEvent) { try { SIPMonitorMachineEvent machineEvent = sipMonitorEvent as SIPMonitorMachineEvent; if (machineEvent != null && !machineEvent.SessionID.IsNullOrBlank() && m_subscriptions.ContainsKey(machineEvent.SessionID)) { SIPEventSubscription subscription = m_subscriptions[machineEvent.SessionID]; lock (subscription) { string resourceURI = (machineEvent.ResourceURI != null) ? machineEvent.ResourceURI.ToString() : null; //logger.Debug("NotifierSubscriptionsManager received new " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + "."); //MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.Monitor, "NotifierSubscriptionsManager received new " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + ".", subscription.SubscriptionDialogue.Owner)); if (subscription.AddMonitorEvent(machineEvent)) { SendNotifyRequestForSubscription(subscription); } //logger.Debug("NotifierSubscriptionsManager completed " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + "."); } return(true); } return(false); } catch (Exception excp) { logger.Error("Exception NotifierSubscriptionsManager MonitorEventAvailable. " + excp.Message); return(false); } }
private void FireProxyLogEvent(SIPMonitorEvent monitorEvent) { try { if (monitorEvent is SIPMonitorConsoleEvent) { SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent; if (TraceLog != null) { TraceLog.AppendLine(consoleEvent.EventType + "=> " + monitorEvent.Message); } } if (Log_External != null) { Log_External(monitorEvent); } } catch (Exception excp) { logger.Error("Exception FireProxyLogEvent DialPlanContext. " + excp.Message); } }
public void Send(SIPMonitorEvent monitorEvent) { try { if (monitorEvent != null && m_sendEvents) { string monitorEventStr = monitorEvent.ToCSV(); //if (monitorEvent.Message != null && monitorEvent.Message.Length > 0) //{ // monitorEventStr = monitorEvent.ToCSV(); //} if (monitorEventStr != null) { m_monitorClient.Send(Encoding.ASCII.GetBytes(monitorEventStr), monitorEventStr.Length, m_monitorEndPoint); } } } catch (Exception excp) { logger.Error("Exception SIPMonitorEventWriter Send (SIPMonitorEvent). " + excp.Message); } }
private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent) { try { if (sipMonitorEvent != null && m_monitorEventWriter != null) { if (sipMonitorEvent is SIPMonitorConsoleEvent) { SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent; if (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace && consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction && consoleEvent.EventType != SIPMonitorEventTypesEnum.Timing && consoleEvent.EventType != SIPMonitorEventTypesEnum.UnrecognisedMessage && consoleEvent.EventType != SIPMonitorEventTypesEnum.NATKeepAliveRelay && consoleEvent.EventType != SIPMonitorEventTypesEnum.BadSIPMessage) { logger.Debug("pr: " + sipMonitorEvent.Message); } if (consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction) { m_monitorEventWriter.Send(sipMonitorEvent); } } else { m_monitorEventWriter.Send(sipMonitorEvent); } } } catch (Exception excp) { logger.Error("Exception FireSIPMonitorEvent. " + excp.Message); } }
public void MonitorEventReceived(SIPMonitorEvent monitorEvent) { throw new NotImplementedException(); }
void statefulProxyCore1_StatefulProxyLogEvent(SIPMonitorEvent logEvent) { Console.WriteLine("AppServerCore1-" + logEvent.EventType + ": " + logEvent.Message); }
/// <summary> /// Rules for displaying events. /// 1. The event type is checked to see if it matches. If no event type has been specified than all events EXCEPT FullSIPTrace are /// matched, /// 2. If the event type is FullSIPTrace then the messages can be filtered on the request type. If the request type is not set all /// SIP trace messages are matched otherwise only those pertaining to the request type specified, /// 3. The server type is checked, if it's not set all events are matched, /// 4. If the event has matched up until this point a decision is now made as to whether to display or reject it: /// a. If the IPAddress filter is set is checked, if it matches the event is displayed otherwise it's rejected, /// b. If the username AND server IP AND request type AND regex filters all match the vent is displayed otherwise rejected. /// </summary> /// <param name="proxyEvent"></param> /// <returns></returns> public bool ShowSIPMonitorEvent(SIPMonitorEvent proxyEvent) { string serverAddress = (proxyEvent.ServerEndPoint != null) ? proxyEvent.ServerEndPoint.SocketEndPoint.Address.ToString() : null; string remoteIPAddress = (proxyEvent.RemoteEndPoint != null) ? proxyEvent.RemoteEndPoint.SocketEndPoint.Address.ToString() : null; string dstIPAddress = (proxyEvent.DestinationEndPoint != null) ? proxyEvent.DestinationEndPoint.SocketEndPoint.Address.ToString() : null; SIPMethodsEnum sipMethod = SIPMethodsEnum.NONE; if (SIPRequestFilter != WILDCARD && proxyEvent.Message != null && proxyEvent.EventType == SIPMonitorEventTypesEnum.FullSIPTrace) { if (ShowEvent(proxyEvent.EventType, proxyEvent.ServerEndPoint)) { if (SIPRequestFilter == SIPREQUEST_INVITE_VALUE) { // Do a regex to pick out ACK's, BYE's , CANCEL's and INVITES. if (Regex.Match(proxyEvent.Message, "(ACK|BYE|CANCEL|INVITE) +?sips?:", RegexOptions.IgnoreCase).Success || Regex.Match(proxyEvent.Message, @"CSeq: \d+ (ACK|BYE|CANCEL|INVITE)(\r|\n)", RegexOptions.IgnoreCase).Success) { return(ShowRegex(proxyEvent.Message)); } else { string reqPattern = SIPRequestFilter + " +?sips?:"; string respPattern = @"CSeq: \d+ " + SIPRequestFilter; if (Regex.Match(proxyEvent.Message, reqPattern, RegexOptions.IgnoreCase).Success || Regex.Match(proxyEvent.Message, respPattern, RegexOptions.IgnoreCase).Success) { return(ShowRegex(proxyEvent.Message)); } } } return(false); } } if (ShowEvent(proxyEvent.EventType, proxyEvent.ServerEndPoint) && ShowServer(proxyEvent.ServerType)) { if (IPAddress != WILDCARD) { if (ShowIPAddress(remoteIPAddress)) { return(true); } else if (ShowIPAddress(dstIPAddress)) { return(true); } else { return(false); } } bool showUsername = ShowUsername(proxyEvent.Username); bool showServerIP = ShowServerIPAddress(serverAddress); bool showRequest = ShowRequest(sipMethod); bool showRegex = ShowRegex(proxyEvent.Message); if (showUsername && showServerIP && showRequest && showRegex) { return(true); } } return(false); }
public List <string> GetNotifications(string address, out string sessionId, out string sessionError) { sessionId = null; sessionError = null; try { //logger.Debug("SIPMonitorClientManager GetNotifications for address " + address + "."); /*lock (m_clientsWaiting) * { * // If there is a callback set for this address the consumer has now received it and it can be removed. * if (m_clientsWaiting.ContainsKey(address)) * { * m_clientsWaiting.Remove(address); * } * }*/ List <SIPMonitorClientSession> sessions = (m_clientSessions.ContainsKey(address)) ? m_clientSessions[address] : null; if (sessions != null) { sessions = sessions.OrderBy(s => s.LastGetNotificationsRequest).ToList(); for (int index = 0; index < sessions.Count; index++) { SIPMonitorClientSession session = sessions[index]; session.LastGetNotificationsRequest = DateTime.Now; if (!session.FilterDescriptionNotificationSent && session.SessionType == SIPMonitorClientTypesEnum.Console) { //logger.Debug("First notifications request after new console client filter set."); session.FilterDescriptionNotificationSent = true; sessionId = session.SessionID; SIPMonitorConsoleEvent filterDescriptionEvent = new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Monitor, SIPMonitorEventTypesEnum.Monitor, session.Filter.GetFilterDescription(), session.CustomerUsername); return(new List <string>() { filterDescriptionEvent.ToConsoleString(session.AdminId) }); } else if (session.Events.Count > 0) { List <string> eventList = new List <string>(); sessionId = session.SessionID; lock (session.Events) { while (session.Events.Count > 0) { SIPMonitorEvent monitorEvent = session.Events.Dequeue(); if (monitorEvent is SIPMonitorConsoleEvent) { eventList.Add(((SIPMonitorConsoleEvent)monitorEvent).ToConsoleString(session.AdminId)); } else { eventList.Add(monitorEvent.ToCSV()); } } } return(eventList); } } } return(null); } catch (Exception excp) { logger.Error("Exception SIPMonitorClientManager GetNotifications. " + excp.Message); sessionError = "Exception SIPMonitorClientManager GetNotifications. " + excp.Message; return(null); //throw; } }
public void MonitorEventReceived(SIPMonitorEvent monitorEvent) { try { monitorEvent.MonitorServerID = m_monitorServerID; //Action<string> notificationReady = null; //string notificationAddress = null; lock (m_clientSessions) { foreach (KeyValuePair <string, List <SIPMonitorClientSession> > sessionEntry in m_clientSessions) { string address = sessionEntry.Key; List <SIPMonitorClientSession> sessions = sessionEntry.Value; bool eventAdded = false; foreach (SIPMonitorClientSession session in sessions) { if (session.Filter.ShowSIPMonitorEvent(monitorEvent)) { //logger.Debug("Session accepted event " + monitorEvent.ClientType + " for session " + monitorEvent.SessionID + "."); monitorEvent.SessionID = session.SessionID; if (session.UDPSocket != null) { SendMonitorEventViaUDP(monitorEvent, session.UDPSocket); } else { if (MonitorEventReady == null || !MonitorEventReady(monitorEvent)) { lock (session.Events) { if (session.Events.Count > MAX_EVENT_QUEUE_SIZE) { // Queue has exceeded max allowed size, pop off the oldest event. session.Events.Dequeue(); } session.Events.Enqueue(monitorEvent); } eventAdded = true; } } } } //if (eventAdded && m_clientsWaiting.ContainsKey(session.Address)) if (eventAdded) { //notificationAddress = session.Address; //notificationReady = m_clientsWaiting[session.Address]; if (NotificationReady != null) { NotificationReady(address); } } } } /*if (notificationReady != null) * { * //logger.Debug("SIPMonitorClientManager Firing notification available callback for address " + notificationAddress + "."); * * try * { * notificationReady(notificationAddress); * } * catch (Exception callbackExcp) * { * logger.Error("Exception SIPMonitorClientManager MonitorEventReceived Callback. " + callbackExcp.Message); * lock (m_clientsWaiting) * { * m_clientsWaiting.Remove(notificationAddress); * } * } * }*/ } catch (Exception excp) { logger.Error("Exception SIPMonitorClientManager MonitorEventReceived. " + excp.Message); } }