protected void RegisterOutgoingRequest(Requests.OutgoingCallRequest request) { if ((request.Source!=default(PhoneNumber) && request.Target!=default(PhoneNumber))&& (GetCallInfo(request.Source) == null && GetConnectionInfo(request.Source) == null)) { var callInfo = new CallInfo() { Source = request.Source, Target = request.Target, Started = DateTime.Now }; ITerminal targetTerminal = GetTerminalByPhoneNumber(request.Target); IPort targetPort = GetPortByPhoneNumber(request.Target); if (targetPort.State == PortState.Free) { _connectionCollection.Add(callInfo); targetPort.State = PortState.Busy; targetTerminal.IncomingRequestFrom(request.Source); } else { OnCallInfoPrepared(this, callInfo); } } }
protected virtual void OnCallInfoPrepared(object sender, CallInfo callInfo) { if (CallInfoPrepared != null) { CallInfoPrepared(sender, callInfo); } }
protected void InterruptConnection(CallInfo callInfo) { this._callCollection.Remove(callInfo); SetPortStateWhenConnectionInterrupted(callInfo.Source, callInfo.Target); OnCallInfoPrepared(this, callInfo); }
protected void MakeCallActive(CallInfo callInfo) { this._connectionCollection.Remove(callInfo); callInfo.Started = DateTime.Now; this._callCollection.Add(callInfo); }
protected void InterruptActiveCall(CallInfo callInfo) { callInfo.Duration = DateTime.Now - callInfo.Started; this._callCollection.Remove(callInfo); SetPortStateWhenConnectionInterrupted(callInfo.Source, callInfo.Target); OnCallInfoPrepared(this, callInfo); }