public async Task <IActionResult> PutSIPCall(Guid id, SIPCall sIPCall) { if (id != sIPCall.ID) { return(BadRequest()); } _context.Entry(sIPCall).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SIPCallExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void Call_CallStateChanged(object sender, CallStateChangedArgs e) { SIPCall call1 = (SIPCall)sender; if (e.State == CallState.Answered) { CallStart.Add(call1.CallID, NpgsqlTypes.NpgsqlDateTime.Now); } if (e.State == CallState.Completed) { NpgsqlTypes.NpgsqlDateTime startValue; if (CallStart.TryGetValue(call1.CallID, out startValue)) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@calling_user_id", call1.CallerIDAsCaller); parameters.Add("@called_user_id", call1.DialInfo.Dialed); parameters.Add("@source_ip", call1.BasicInfo.Owner.InstanceInfo.Transport.RemoteEndPoint.ToString()); parameters.Add("@start_billing", startValue); parameters.Add("@stop_billing", NpgsqlTypes.NpgsqlDateTime.Now); parameters.Add("@call_id", call1.CallID); string command = "insert into billing (calling_user_id, called_user_id, source_ip, start_billing, stop_billing, call_id)" + "values(@calling_user_id, @called_user_id, @source_ip, @start_billing, @stop_billing, @call_id)"; _database.WriteDataToDB(command, parameters); CallStart.Remove(call1.CallID); } } }
static void Main(string[] args) { StartCall("e:\\config-teste.xml"); return; Dictionary <String, Object> config = new Dictionary <string, object>(); config.Add("host", "10.0.0.200"); config.Add("username", "iam"); config.Add("password", "1234"); List <String> iData = new List <string>(); iData.Add("41-98932694"); iData.Add("(41) 3086-1947"); CodeManagerPluginBase tst = new SIPCall(); List <CodeData> cd = tst.ParseData(iData); tst.SendCode(config, iData, cd[0].DataId, "Teste"); while (true) { Console.ReadLine(); } }
/// <summary> /// Retrieves the other end of a call given the dialogue from one end. /// </summary> /// <param name="dialogue"></param> /// <returns></returns> public SIPDialogue GetOppositeDialogue(SIPDialogue dialogue) { if (dialogue.BridgeId != Guid.Empty) { SIPCall sipCall = m_sipCallDataLayer.Get(d => d.BridgeID == dialogue.BridgeId && d.ID != dialogue.Id); return((sipCall != null) ? sipCall.ToSIPDialogue() : null); } else { return(null); } }
public async Task <ActionResult <SIPCall> > PostSIPCall(SIPCall sIPCall) { _context.SIPCalls.Add(sIPCall); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (SIPCallExists(sIPCall.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetSIPCall", new { id = sIPCall.ID }, sIPCall)); }
public SIPDialogue GetDialogue(string callId, string localTag, string remoteTag) { SIPCall sipCall = m_sipCallDataLayer.Get(d => d.CallID == callId && d.LocalTag == localTag && d.RemoteTag == remoteTag); if (sipCall != null) { //logger.Debug("SIPDialogueManager dialogue match correctly found on dialogue hash."); return(sipCall.ToSIPDialogue()); } else { // Try on To tag. sipCall = m_sipCallDataLayer.Get(d => d.LocalTag == localTag); if (sipCall != null) { logger.LogWarning("SIPDialogueManager dialogue match found on fallback mechanism of To tag."); return(sipCall.ToSIPDialogue()); } // Try on From tag. sipCall = m_sipCallDataLayer.Get(d => d.RemoteTag == remoteTag); if (sipCall != null) { logger.LogWarning("SIPDialogueManager dialogue match found on fallback mechanism of From tag."); return(sipCall.ToSIPDialogue()); } // As an experiment will try on the Call-ID as well. However as a safeguard it will only succeed if there is only one instance of the // Call-ID in use. Since the Call-ID is not mandated by the SIP standard as being unique there it may be that matching on it causes more // problems then it solves. sipCall = m_sipCallDataLayer.Get(d => d.CallID == callId); if (sipCall != null) { logger.LogWarning("SIPDialogueManager dialogue match found on fallback mechanism of Call-ID."); return(sipCall.ToSIPDialogue()); } } return(null); }
protected override void ProcessConversation() { { var stream = new PDUStreamBasedProvider(this.CurrentConversation, EfcPDUProviderType.SingleMessage); var reader = new PDUStreamReader(stream, Encoding.Default); do { this.OnBeforeProtocolParsing(); //Parse protocol.... SIPMsg _message; _message = new SIPMsg(reader); if (!_message.Valid) { this.SnooperExport.TimeStampFirst = _message.Timestamp; this.SnooperExport.AddExportReport( ExportReport.ReportLevel.Warn, this.Name, "parsing of SIP message failed, frame numbers: " + string.Join(",", _message.Frames) + ": " + _message.InvalidReason, _message.ExportSources); Console.WriteLine("parsing of SIP message failed, frame numbers: " + string.Join(",", _message.Frames) + ": " + _message.InvalidReason); continue; } this.OnAfterProtocolParsing(); //Console.WriteLine("successful parsing: frame " + string.Join(",", _message.FrameNumbers.ToArray())); //Do some magic... SIPEvent _event; if (this._eventsDictionary.TryGetValue(_message.Headers.CallID, out _event)) { //Event already present switch (_event.Type) { case SIPEventType.Authentization: //Console.WriteLine("authentication "+_message.Headers.CallID+" present"); _event.Update(_message); break; case SIPEventType.Call: //Console.WriteLine("call "+_message.Headers.CallID+" present"); _event.Update(_message); break; case SIPEventType.Unknown: var oldEvent = _event as SIPUnknownEvent; if (this.PossibleCall(_message)) { this._eventsDictionary.Remove(_message.Headers.CallID); this.SnooperExport.DiscardExportObject(_event); _event = new SIPCall(this.SnooperExport); this._eventsDictionary.Add(_message.Headers.CallID, _event); _event.UpdateFromUnkownEvent(oldEvent); } else if (this.PossibleAuthentization(_message)) { this._eventsDictionary.Remove(_message.Headers.CallID); this.SnooperExport.DiscardExportObject(_event); _event = new SIPAuthentization(this.SnooperExport); this._eventsDictionary.Add(_message.Headers.CallID, _event); _event.UpdateFromUnkownEvent(oldEvent); } _event.Update(_message); break; default: Console.WriteLine("unknown event " + _message.Headers.CallID + " present"); //TODO throw some exception break; } } else { //New event, create if (_message.Type == SIPMsg.SIPMsgType.Request && _message.RequestLine.Method == "REGISTER") { _event = new SIPAuthentization(this.SnooperExport); this._eventsDictionary.Add(_message.Headers.CallID, _event); //Console.WriteLine("authentication " + _message.Headers.CallID + " added"); _event.Update(_message); } else if (_message.Type == SIPMsg.SIPMsgType.Request && _message.RequestLine.Method == "INVITE") { _event = new SIPCall(this.SnooperExport); this._eventsDictionary.Add(_message.Headers.CallID, _event); //Console.WriteLine("call " + _message.Headers.CallID + " added"); _event.Update(_message); } else // type can't be easily decided { if (this.PossibleCall(_message)) { _event = new SIPCall(this.SnooperExport); } else if (this.PossibleAuthentization(_message)) { _event = new SIPAuthentization(this.SnooperExport); } else { _event = new SIPUnknownEvent(this.SnooperExport); } this._eventsDictionary.Add(_message.Headers.CallID, _event); _event.Update(_message); } } // this.eventExporter.AddExportedData(); //Export some meaningful message, object, what so ever... // this.eventExporter.AddExportReport(); //Export problem, exception some meaningful note that will be part of exported data object or export report in case that no data were exported between two escalation of BeforeProtocolParsing //Console.WriteLine(_message.ToString()); } while(reader.NewMessage()); //Export this.OnBeforeDataExporting(); var _callCounter = 0; foreach (var kvp in this._eventsDictionary) { if (kvp.Value.Type == SIPEventType.Unknown) { this.SnooperExport.DiscardExportObject(kvp.Value); } else { if (kvp.Value is SIPCall) { // Process RTP flows of every call var s = kvp.Value as SIPCall; //s.CallId = _callCounter.ToString(); // Pass it inside the call //s.SetExportedPayloads(this.ProcessRTP(s.RTPAddresses, _callCounter.ToString())); ++_callCounter; } //Console.WriteLine("event " + kvp.Key); //Console.WriteLine(kvp.Value.ToString()); kvp.Value.ExportValidity = ExportValidity.ValidWhole; //TODO there should be list of guids (frames, other objects) //kvp.Value.ExportSources.Add(this.CurrentConversation); //todo switch to used PDUs this.SnooperExport.AddExportObject(kvp.Value); } } this.OnAfterDataExporting(); //Clean event dictionary this._eventsDictionary.Clear(); } }