private void SIPRequestInTraceEvent(SIPEndPoint localEP, SIPEndPoint remoteEP, SIPRequest sipRequest) { logger.LogDebug($"Request Received {localEP}<-{remoteEP}: {sipRequest.StatusLine}."); if (_homerSIPClient != null) { var hepBuffer = HepPacket.GetBytes(remoteEP, localEP, DateTime.Now, 333, "myHep", sipRequest.ToString()); _homerSIPClient.SendAsync(hepBuffer, hepBuffer.Length, HOMER_SERVER_ADDRESS, HOMER_SERVER_PORT); } }
/// <summary> /// Enable detailed SIP log messages. /// </summary> private static void EnableTraceLogs(SIPTransport sipTransport) { UdpClient homerSIPClient = null; if (HOMER_SERVER_ADDRESS != null) { homerSIPClient = new UdpClient(0, AddressFamily.InterNetwork); } sipTransport.SIPRequestInTraceEvent += (localEP, remoteEP, req) => { Log.LogDebug($"Request received: {localEP}<-{remoteEP}"); Log.LogDebug(req.ToString()); if (homerSIPClient != null) { var hepBuffer = HepPacket.GetBytes(remoteEP, localEP, DateTime.Now, 333, "myHep", req.ToString()); homerSIPClient.SendAsync(hepBuffer, hepBuffer.Length, HOMER_SERVER_ADDRESS, HOMER_SERVER_PORT); } }; sipTransport.SIPRequestOutTraceEvent += (localEP, remoteEP, req) => { Log.LogDebug($"Request sent: {localEP}->{remoteEP}"); Log.LogDebug(req.ToString()); if (homerSIPClient != null) { var hepBuffer = HepPacket.GetBytes(localEP, remoteEP, DateTime.Now, 333, "myHep", req.ToString()); homerSIPClient.SendAsync(hepBuffer, hepBuffer.Length, HOMER_SERVER_ADDRESS, HOMER_SERVER_PORT); } }; sipTransport.SIPResponseInTraceEvent += (localEP, remoteEP, resp) => { Log.LogDebug($"Response received: {localEP}<-{remoteEP}"); Log.LogDebug(resp.ToString()); if (homerSIPClient != null) { var hepBuffer = HepPacket.GetBytes(remoteEP, localEP, DateTime.Now, 333, "myHep", resp.ToString()); homerSIPClient.SendAsync(hepBuffer, hepBuffer.Length, HOMER_SERVER_ADDRESS, HOMER_SERVER_PORT); } }; sipTransport.SIPResponseOutTraceEvent += (localEP, remoteEP, resp) => { Log.LogDebug($"Response sent: {localEP}->{remoteEP}"); Log.LogDebug(resp.ToString()); if (homerSIPClient != null) { var hepBuffer = HepPacket.GetBytes(localEP, remoteEP, DateTime.Now, 333, "myHep", resp.ToString()); homerSIPClient.SendAsync(hepBuffer, hepBuffer.Length, HOMER_SERVER_ADDRESS, HOMER_SERVER_PORT); } }; sipTransport.SIPRequestRetransmitTraceEvent += (tx, req, count) => { Log.LogDebug($"Request retransmit {count} for request {req.StatusLine}, initial transmit {DateTime.Now.Subtract(tx.InitialTransmit).TotalSeconds.ToString("0.###")}s ago."); }; sipTransport.SIPResponseRetransmitTraceEvent += (tx, resp, count) => { Log.LogDebug($"Response retransmit {count} for response {resp.ShortDescription}, initial transmit {DateTime.Now.Subtract(tx.InitialTransmit).TotalSeconds.ToString("0.###")}s ago."); }; }