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 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); } }
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; } }