/// <summary> /// Creates phone call information. /// </summary> /// /// <param name="callID">The identifier of the call.</param> /// <param name="phoneLineInfo">Associated phone line information.</param> /// <param name="dial">Dialed string.</param> /// <param name="type">The type of the call (incoming/outgoing).</param> public PhoneCallInfo(string callID, PhoneLineInfo phoneLineInfo, string dial, CallDirection type) { CallID = callID; PhoneLineInfo = phoneLineInfo; Dial = dial; Direction = type; }
public Call(Contact contact, ContactPhone contactPhone, DateTime callTime, CallDirection callDirection) { Contact = contact; ContactPhone = contactPhone; CallTime = callTime; CallDirection = callDirection; }
private void OnTimerEvent(Object source, ElapsedEventArgs e) { Random rand = new Random(); CallDirection callDirection = rand.NextDouble() > 0.2 ? CallDirection.Incoming : CallDirection.Outgoing; DateTime callTime = DateTime.Now; Contact contact; Call call; double nextDouble = rand.NextDouble(); if (nextDouble < 0.33) { contact = new Contact("+380675432523"); call = new Call(contact, ContactPhone.Phone1, callTime, callDirection); } else if (nextDouble < 0.66) { contact = new Contact("+380631890789", "044556699"); ContactPhone contactPhone = rand.NextDouble() > 0.4 ? ContactPhone.Phone1 : ContactPhone.Phone2; call = new Call(contact, contactPhone, callTime, callDirection); } else { contact = new Contact("+380983335768"); call = new Call(contact, ContactPhone.Phone1, callTime, callDirection); } Console.WriteLine(call.GetContactPhone() + " " + callDirection + " " + call.CallTime); RaiseCallReceivedEvent(call); }
public static string FuncCallString(CallDirection direction) { string result; switch (direction) { case CallDirection.Client2GameServer: result = "CG"; break; case CallDirection.GameServer2Client: result = "GC"; break; case CallDirection.Server2Server: result = "SS"; break; case CallDirection.Client2Server: result = "CS"; break; case CallDirection.Server2Client: result = "SC"; break; case CallDirection.Skip: result = "SKIP"; break; default: throw new ArgumentOutOfRangeException("direction"); } return(result); }
/// <summary> /// Extracts information from IPhoneCall object. /// </summary> /// <param name="call">The phone call object as information source.</param> /// <returns>The information about phone call.</returns> public static PhoneCallInfo AsPhoneCallInfo(this IPhoneCall call) { PhoneLineInfo pli = call.PhoneLine.AsPhoneLineInfo(); CallDirection type = (call.IsIncoming) ? CallDirection.Incoming : CallDirection.Outgoing; return(new PhoneCallInfo(call.CallID, pli, call.OtherParty.UserName, type)); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="accountSid"></param> /// <param name="sid"></param> /// <param name="direction"></param> /// <param name="caller"></param> /// <param name="called"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="culture"></param> internal CallContext(string accountSid, string sid, CallDirection direction, CallEndpoint caller, CallEndpoint called, CallEndpoint from, CallEndpoint to, CultureInfo culture) { AccountSid = accountSid; Sid = sid; Direction = direction; Caller = caller; Called = called; From = from; To = to; Culture = culture; }
/// <summary> /// Returns the low-level FreeSWITCH string corresponding to a <see cref="CallDirection" />. /// </summary> /// <param name="direction">The direction code.</param> /// <returns>The corresponding string or <see cref="Empty" /> if the code is unknown.</returns> public static string GetSwitchHangupReasonString(CallDirection direction) { string directionString; if (!callDirectionToString.TryGetValue(direction, out directionString)) { SysLog.LogWarning("Unexpected call direction code [{0}].", direction); directionString = string.Empty; } return(directionString); }
public static string GetCallDirection(CallDirection direction) { string callDirection = "Inbound"; switch (direction) { case CallDirection.Outbound: callDirection = "Outbound"; break; } return(callDirection); }
public void AddCallToListView(ListView listview) { if (listview.InvokeRequired) { listview.Invoke(new Action <ListView>(AddCallToListView), listview); } else { if (Calls.Count > 1) { listview.Items.RemoveAt(0); } listview.Items.Insert(0, new ListViewItem(new[] { Name, Number, CallDirection.ToString(), lastCallTime.ToString(), $"{lastCallDuration.Minutes.ToString()}:{lastCallDuration.Seconds.ToString()}", Calls.Count.ToString() })); } }
public Form1() { InitializeComponent(); logs = ""; callState = false; callRinging = false; connectState = false; ippbx = new Ippbx(); callDir = CallDirection.None; this.ShowInTaskbar = false; db = new LiteDatabase(@"nwrtelephony"); collection = db.GetCollection <Recording>("recording"); dtdt = new DTMF(); ringer = new SoundPlayer(Properties.Resources.telephone_ring_04); }
private Call GetOrInsert(int id, CallStatus status, CallDirection direction) { if (_calls.ContainsKey(id)) { return(_calls[id]); } var call = new Call(_codec, id) { Status = status, Direction = direction }; _lock.Enter(); _calls.Add(id, call); _lock.Leave(); return(call); }
void cti_OnCompletedCall(string CallID, string src, string dst, int duration, string start, string end, int direction, string record) { log.Debug("CallCompleted detected from " + src + " to " + dst + "Direction:" + direction); TimeSpan span = TimeSpan.FromSeconds(duration); TimeSpan spanst = TimeSpan.FromSeconds(Convert.ToInt64(start)); DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); //как оказалось,в этом решении шифруются даты как кол-во секунд, прошедших с 1 янв. 1970 года DateTime startdate = origin.AddSeconds(Convert.ToInt64(start)); DateTime stopdate = origin.AddSeconds(Convert.ToInt64(end)); CallDirection calldirection = direction == 0 ? CallDirection.Incoming : CallDirection.Outgoing; // Convert.ToDateTime(spanst.Seconds); if (CompletedCall != null) { CompletedCall(this, new CallsEventArgs { CallID = CallID, dstPhone = dst, srcPhone = src, Duration = span, Start = startdate, Stop = stopdate, CallDirection = calldirection }); } }
public override bool Equals(object anotherObject) { if (anotherObject == null) { return(false); } if (ReferenceEquals(this, anotherObject)) { return(true); } if (this.GetType() != anotherObject.GetType()) { return(false); } Call anotherCall = (Call)anotherObject; bool contactIsTheSame = Contact.Equals(anotherCall.Contact); bool callDirectionIsTheSame = CallDirection.CompareTo(anotherCall.CallDirection) == 0; return(contactIsTheSame && callDirectionIsTheSame); }
public CallInfo(CallDirection callDirection, long duration, long time) { this.callDirection = callDirection; this.duration = duration; this.time = time; }
private void AddCallToHistory(PhoneLineInfo line, string dial, CallDirection type) { PhoneCallInfo info = new PhoneCallInfo(line, dial, type); softphoneEngine.AddCallToHistory(info); lbCallHistory.Items.Add(info); }
object UpdateCallsThread(object obj) { Stopwatch sw = new Stopwatch(); sw.Start(); #if DEBUG CrestronConsole.Print("Checking for calls..."); #endif IEnumerable <XElement> xCalls = Codec.RequestPath("Status/Call"); if (xCalls != null) { #if DEBUG CrestronConsole.PrintLine(" Call count = {0}", xCalls.Count()); #endif Dictionary <int, Call> receivedCalls = new Dictionary <int, Call>(); foreach (XElement xCall in xCalls) { bool statusChanged = false; int callID = int.Parse(xCall.Attribute("item").Value); Call call; if (_Calls.ContainsKey(callID)) { call = _Calls[callID]; } else { call = new Call(Codec, callID); _Calls.Add(callID, call); } receivedCalls.Add(call.ID, call); foreach (XElement e in xCall.Elements()) { switch (e.XName.LocalName) { case "AnswerState": CallAnswerState _AnswerState = (CallAnswerState)Enum.Parse(typeof(CallAnswerState), e.Value, false); if (_AnswerState != call.AnswerState) { call.AnswerState = _AnswerState; statusChanged = true; } break; case "CallType": CallType _Type = (CallType)Enum.Parse(typeof(CallType), e.Value, false); if (_Type != call.Type) { call.Type = _Type; statusChanged = true; } break; case "CallbackNumber": call.CallbackNumber = e.Value; if (call.CallbackNumber != e.Value) { call.CallbackNumber = e.Value; statusChanged = true; } break; case "DeviceType": CallDeviceType _DeviceType = (CallDeviceType)Enum.Parse(typeof(CallDeviceType), e.Value, false); if (call.DeviceType != _DeviceType) { call.DeviceType = _DeviceType; statusChanged = true; } break; case "Direction": CallDirection _Direction = (CallDirection)Enum.Parse(typeof(CallDirection), e.Value, false); if (call.Direction != _Direction) { call.Direction = _Direction; statusChanged = true; } break; case "Duration": TimeSpan duration = TimeSpan.Parse(e.Value); call.StartTime = DateTime.Now - duration; break; case "DisplayName": call.DisplayName = e.Value; if (call.DisplayName != e.Value) { call.DisplayName = e.Value; statusChanged = true; } break; case "Protocol": call.Protocol = e.Value; if (call.Protocol != e.Value) { call.Protocol = e.Value; statusChanged = true; } break; case "RemoteNumber": call.RemoteNumber = e.Value; if (call.RemoteNumber != e.Value) { call.RemoteNumber = e.Value; statusChanged = true; } break; case "Status": CallStatus _Status = (CallStatus)Enum.Parse(typeof(CallStatus), e.Value, false); if (_Status != call.Status && !(_Status == CallStatus.Disconnecting && call.Status == CallStatus.Idle)) { call.Status = _Status; statusChanged = true; } break; } } if (statusChanged) { OnCallStatusChange(call, CallInfoChangeNotificationSource.UpdateRequest); } } foreach (Call call in this.Active) { if (!receivedCalls.ContainsKey(call.ID)) { call.Status = CallStatus.Idle; OnCallStatusChange(call, CallInfoChangeNotificationSource.UpdateRequest); call.Ghost = true; if (this.Codec.LoggingEnabled) { this.Codec.Logger.Log("Call id {0} was found in Codec.Calls but not present in an Update Request, Call was removed and notified as idle", call.ID); } } } } else { #if DEBUG CrestronConsole.PrintLine(" No Calls"); #endif } return(null); }
internal static extern int GetCallDirection(IntPtr handle, out CallDirection direction);
private void connect() { if (string.IsNullOrEmpty(ippbx.hosts) || string.IsNullOrEmpty(ippbx.extension) || string.IsNullOrEmpty(ippbx.password)) { MessageBox.Show("IPPBX parameter not complete", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { invokeUpdateLog("Registering ..."); string pwd = Common.passwordToAsterixs(ippbx.password); invokeUpdateLog("Extension:" + ippbx.extension + " password:"******" hosts:" + ippbx.hosts); account = new Account(ippbx.extension, ippbx.password, ippbx.hosts); phone = new Phone(account); phone.PhoneConnectedEvent += delegate() { invokeUpdateLog("connected"); ws.send("register|success"); Properties.Settings.Default["pbx_hosts"] = ippbx.hosts; Properties.Settings.Default["pbx_extension"] = ippbx.extension; Properties.Settings.Default["pbx_password"] = ippbx.password; Properties.Settings.Default["pbx_caller"] = ippbx.hosts; Properties.Settings.Default.Save(); invokeUpdateTelepohyInfo(); }; phone.PhoneDisconnectedEvent += delegate() { invokeUpdateLog("Disconnected"); ws.send("register|disconnect"); }; phone.CallCompletedEvent += delegate(Call call) { callRinging = false; callDir = CallDirection.None; if (recorder != null) { recorder.stopRecordInput(); recorder.stopRecordOutput(); } invokeUpdateLog("Call complete"); callerIdentity = null; ws.send("call|completed"); notifyIcon1.BalloonTipTitle = "Call Completed"; notifyIcon1.BalloonTipText = "Call completed"; notifyIcon1.ShowBalloonTip(10000000); ringer.Stop(); }; phone.CallActiveEvent += delegate(Call call) { ringer.Stop(); callState = true; callRinging = false; this.call = call; if (this.callerIdentity != null && (this.callerIdentity.Extension != null && this.callerIdentity.Extension.Equals("") == false)) { phone.SendDTMFs(call, callerIdentity.Extension); } invokeUpdateLog("On Call"); if (callDir == CallDirection.Inbound) { recorder = new Recorder(inboundCallerId); } else { recorder = new Recorder(txtExt.Text); } recorder.startRecordInput(); recorder.startRecordOutput(); recorder.CombineComplete += (s, e) => { Recording recording = recorder.getRecording(); if (callDir == CallDirection.Inbound) { recording.Direction = Recording.RecDirection.Inbound; } else { recording.Direction = Recording.RecDirection.Outbound; } recording.Status = Recording.RecStatUpload.Unuploaded; invokeUpdateLog("Recording : " + recording.Filename); ws.send("recording|" + recording.Filename); collection.Insert(recording); }; ws.send("call|active"); }; phone.LoadEvent += delegate(Call call) { callRinging = true; this.call = call; invokeUpdateLog("Ringging"); ws.send("call|ringing"); }; phone.IncomingCallEvent += delegate(Call call) { this.call = call; callRinging = true; callDir = CallDirection.Inbound; callState = false; inboundCallerId = Common.getExtensionNumberFromCall(call.GetFrom()); invokeUpdateLog("Incoming Call from " + inboundCallerId); ws.send("call|incoming|" + inboundCallerId); notifyIcon1.BalloonTipTitle = "Incoming Call"; notifyIcon1.BalloonTipText = "Incoming call from " + inboundCallerId; notifyIcon1.ShowBalloonTip(1); ringer.Play(); }; phone.Connect(); this.connectState = true; if (button2.InvokeRequired) { lblExt.Invoke(new MethodInvoker(delegate { button2.Enabled = true; })); } else { button2.Enabled = true; } } }
public Call(Contact contact, DateTime time, CallDirection directon) { this.Contact = contact; this.Time = time; this.Direction = directon; }
internal static extern Telephony.TelephonyError GetDirection(IntPtr callHandle, out CallDirection direction);
public override int GetHashCode() { return(Caller.GetHashCode() ^ CallDirection.GetHashCode()); }
/// <summary> /// Gets some information about the last call /// </summary> /// <param name="type">The type of the call (incoming/outgoing)</param> /// <returns></returns> public PhoneCallInfo GetLastCall(CallDirection type) { return callHistory.FindLast(delegate(PhoneCallInfo info) { return info.Direction == type; }); }
public void AddCallToListView(ListView listview) { if (listview.InvokeRequired) { listview.Invoke(new Action <ListView>(AddCallToListView), listview); } else { listview.Items.Insert(0, new ListViewItem(new[] { ContactName, ContactNumber, CallDirection.ToString(), CallTime.ToString(), $"{CallDuration.Minutes.ToString()}:{CallDuration.Seconds.ToString()}" })); } }