public async Task <IHttpActionResult> Post(KamailioSipEvent sipEvent) { if (!_settingsManager.UseSipEvent) { if (log.IsTraceEnabled) { log.Warn("Receiving event but receiver is not ON for 'UseSipEvent'"); } return(Ok()); } if (log.IsTraceEnabled) { Stream stream = await Request.Content.ReadAsStreamAsync(); stream.Seek(0, SeekOrigin.Begin); var body = await Request.Content.ReadAsStringAsync(); log.Trace($"Request {Request} Body {body}"); } using (new TimeMeasurer("Incoming SIP event")) { if (sipEvent == null) { log.Warn("SIP event controller received empty data"); return(BadRequest()); } var sipMessage = _sipEventParser.Parse(sipEvent); if (sipMessage == null) { log.Warn("Incorrect SIP message format: ", sipEvent); return(BadRequest()); } SipEventHandlerResult result = _sipMessageManager.HandleSipMessage(sipMessage); if (log.IsDebugEnabled) { log.Debug("SIP message, Handled: {0}, Parsed: {1}, Result: {2}", sipEvent.ToLogString(), 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 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 ActionResult EditRegisteredSipComment(SipAccountComment model) { if (model.SipAccountId != Guid.Empty) { _sipAccountManager.UpdateComment(model.SipAccountId, model.Comment); } var updateResult = new SipEventHandlerResult() { ChangeStatus = SipEventChangeStatus.CodecUpdated, ChangedObjectId = model.SipAccountId }; _guiHubUpdater.Update(updateResult); // First web gui _statusHubUpdater.Update(updateResult); // Then codec status to external clients return(null); }
public ActionResult EditRegisteredSipComment(RegisteredSipComment sipComment) { if (sipComment.RegisteredSipId != Guid.Empty) { _userManager.SaveComment(sipComment); } var updateResult = new KamailioMessageHandlerResult() { ChangeStatus = KamailioMessageChangeStatus.CodecUpdated, ChangedObjectId = sipComment.RegisteredSipId }; _guiHubUpdater.Update(updateResult); _statusHubUpdater.Update(updateResult); return(null); }
public IHttpActionResult Post([FromBody] string message) { log.Debug("Incoming Kamailio message: {0}", message); if (string.IsNullOrWhiteSpace(message)) { log.Warn("Kamailio event controller received empty data"); return(BadRequest()); } KamailioMessageHandlerResult result = _sipMessageManager.HandleMessage(message); if (result == null) { log.Warn("Kamailio message was handled but result was null"); } else if (result.ChangeStatus != KamailioMessageChangeStatus.NothingChanged) { _guiHubUpdater.Update(result); // First web gui _statusHubUpdater.Update(result); // Then codec status to external clients } return(Ok()); }