public IHttpActionResult Post([FromBody] string message) { if (!_settingsManager.UseOldKamailioEvent) { if (log.IsTraceEnabled) { log.Warn("Receiving event but receiver is not ON for 'UseOldKamailioEvent'"); } return(Ok()); } using (new TimeMeasurer("Incoming Kamailio event")) { if (string.IsNullOrWhiteSpace(message)) { log.Warn("Kamailio event controller received empty data"); return(BadRequest()); } SipMessageBase sipMessage = _kamailioMessageParser.Parse(message); if (sipMessage == null) { log.Warn("Incorrect Kamailio message format: {0}", message); return(BadRequest()); } SipEventHandlerResult result = _sipMessageManager.HandleSipMessage(sipMessage); if (log.IsDebugEnabled) { log.Debug("SIP message, Handled: {0}, Parsed: {1}, Result: {2}", message, sipMessage.ToDebugString(), result?.ChangeStatus); } if (result == null) { log.Warn("Kamailio message was handled but result was null"); } else if (result.ChangeStatus != SipEventChangeStatus.NothingChanged) { _guiHubUpdater.Update(result); // First web gui _statusHubUpdater.Update(result); // Then codec status to external clients } return(Ok()); } }
public KamailioMessageHandlerResult HandleMessage(string message) { KamailioMessageBase sipMessage = _kamailioMessageParser.Parse(message); if (sipMessage == null) { log.Warn("Incorrect Kamailio message format: {0}", message); return(new KamailioMessageHandlerResult { ChangeStatus = KamailioMessageChangeStatus.NothingChanged }); } if (log.IsInfoEnabled) { log.Debug("Parsed Kamailio Message {0}", sipMessage.ToDebugString()); } var kamailioMessageResult = DoHandleMessage(sipMessage); log.Debug("Handled Kamailio message with result {0}. {1}", kamailioMessageResult.ChangeStatus, sipMessage.ToDebugString()); return(kamailioMessageResult); }