Exemplo n.º 1
0
        protected void RegisterOutgoingRequest(Requests.OutgoingRequest request)
        {
            if ((request.Source != default(PhoneNumber) && request.Target != default(PhoneNumber)) &&
                (GetCallInfo(request.Source) == null && GetConnectionInfo(request.Source) == null))
            {
                var callInfo = new CallInfo()
                {
                    Tariff = GetTariffByPhoneNumber(request.Source),
                    Caller = request.Source,
                    Target = request.Target,
                    TimeOfCalling = DateTime.Now
                };

                ITerminal targetTerminal = GetTerminalByPhoneNumber(request.Target);
                IPort targetPort = GetPortByPhoneNumber(request.Target);
                IPort sourcePort = GetPortByPhoneNumber(request.Source);

                if (targetPort.State == PortState.connected)
                {
                    _connectionCollection.Add(callInfo);
                    targetPort.State = PortState.calling;
                    targetTerminal.IncomingRequestFrom(request.Source);
                }
                else
                {
                    sourcePort.State = PortState.connected;
                    OnCallInfoPrepared(this, callInfo);
                }
            }
        }
Exemplo n.º 2
0
 protected virtual void OnCallInfoPrepared(object sender, CallInfo callInfo)
 {
     if (CallInfoPrepared != null)
     {
         CallInfoPrepared(sender, callInfo);
     }
 }
Exemplo n.º 3
0
 protected void InterruptConnection(CallInfo callInfo)
 {
     this._callCollection.Remove(callInfo);
     SetPortStateWhenConnectionInterrupted(callInfo.Caller, callInfo.Target);
     OnCallInfoPrepared(this, callInfo);
 }
Exemplo n.º 4
0
 protected void MakeCallActive(CallInfo callInfo)
 {
     this._connectionCollection.Remove(callInfo);
     callInfo.TimeOfCalling = DateTime.Now;
     this._callCollection.Add(callInfo);
 }
Exemplo n.º 5
0
 protected void InterruptActiveCall(CallInfo callInfo)
 {
     Thread.Sleep(1000);
     callInfo.Duration = DateTime.Now - callInfo.TimeOfCalling;
     this._callCollection.Remove(callInfo);
     SetPortStateWhenConnectionInterrupted(callInfo.Caller, callInfo.Target);
     OnCallInfoPrepared(this, callInfo);
 }