private void Channel_UnsolicitedEvent(object sender, UnsolicitedEventArgs e) { if (e.Line1 == "RING") { IncomingCall?.Invoke(this, new IncomingCallEventArgs()); } else if (e.Line1.StartsWith("VOICE CALL: BEGIN")) { CallStarted?.Invoke(this, new CallStartedEventArgs()); } else if (e.Line1.StartsWith("VOICE CALL: END")) { CallEnded?.Invoke(this, CallEndedEventArgs.CreateFromResponse(e.Line1)); } else if (e.Line1.StartsWith("MISSED_CALL: ")) { MissedCall?.Invoke(this, MissedCallEventArgs.CreateFromResponse(e.Line1)); } else if (e.Line1.StartsWith("+CMTI: ")) { SmsReceived?.Invoke(this, SmsReceivedEventArgs.CreateFromResponse(e.Line1)); } else if (e.Line1.StartsWith("+CUSD: ")) { UssdResponseReceived?.Invoke(this, UssdResponseEventArgs.CreateFromResponse(e.Line1)); } else if (e.Line1.StartsWith("+CME ERROR:")) { ErrorReceived?.Invoke(this, ErrorEventArgs.CreateFromCmeResponse(e.Line1)); } else if (e.Line1.StartsWith("+CMS ERROR:")) { ErrorReceived?.Invoke(this, ErrorEventArgs.CreateFromCmsResponse(e.Line1)); } }
private void AgentManager_AgentCreated(object sender, AddedAgentEventArgs args) { if (!_agentsWithTaskCancellationTokenSources.ContainsKey(args.NewAgent.Name)) { var agent = args.NewAgent; var cts = new CancellationTokenSource(); var ctoken = cts.Token; Task.Factory.StartNew(() => { ctoken.ThrowIfCancellationRequested(); while (!ctoken.IsCancellationRequested) { if (_queueOfCalls.TryDequeue(out var call)) { CallStarted?.Invoke(this, new CallProcessingStartedEventArgs { CallAnswerer = agent, PrecessedCall = call }); Thread.Sleep(call.DurationInSec * 1000); CallEnded?.Invoke(this, new CallProcessingEndedEventArgs { CallAnswerer = agent, PrecessedCall = call }); } } }, ctoken, TaskCreationOptions.LongRunning, TaskScheduler.Default); _agentsWithTaskCancellationTokenSources.TryAdd(args.NewAgent.Name, cts); } }
private void HandleCallStarted(Started started) { var eventToStore = new CallStarted { ConversationId = Guid.Parse(FormatUuid(started.ConversationUuid)), From = started.From, To = started.To }; // Create an individual stream per phone conversation. this._session.Events.Append(eventToStore.ConversationId, eventToStore); }
public void CloseCall() { // Close capture file captureFileWriter.Close(); // Create details file using (StreamWriter sr = new StreamWriter(File.OpenWrite(SIPPacketFilePath + "\\" + CallID + ".txt"))) { sr.WriteLine(string.Format("{0,-20}: {1}", "Call Started", CallStarted.ToString())); sr.WriteLine(string.Format("{0,-20}: {1}", "Callee", this.CalleeIP.ToString())); // sr.WriteLine(string.Format("{0,-20}: {1}", "Callee ID", this.CalleeID.ToString())); sr.WriteLine(string.Format("{0,-20}: {1}", "Caller", this.CallerIP.ToString())); // sr.WriteLine(string.Format("{0,-20}: {1}", "Caller ID", this.CallerID.ToString())); sr.WriteLine(string.Format("{0,-20}: {1}", "Hungup", this.WhoHungUp.ToString())); } }
public void Apply(CallStarted started) { this.From = started.From; this.To = started.To; }
public void CallMe(string mess) { CallStarted?.Invoke(mess); }
private void CallStarted(CallStarted callStarted) { _status = AgentCallStatus.InCall; }
private void OnCallStart(CallStarted started) { _chat = started.Call.Chat; _visuals.Add(_excuseButton); Branch.Add(_excuseButton); }