예제 #1
0
 public void AddCallInfo(CallInfo callInfo)
 {
     _callCollection.Add(callInfo);
     OnCallInfoAdded(this, callInfo);
 }
예제 #2
0
        protected void InterruptConnection(CallInfo connection)
        {
            var sourceTerminal = GetTerminal(connection.Source);
            var sourcePort = GetPort(sourceTerminal);

            var targetTerminal = GetTerminal(connection.Target);
            var targetPort = GetPort(targetTerminal);

            var cl = GetLastConnectionInfo(connection.Target);
            if (connection == cl && targetPort.State != PortState.Off)
            {
                connection.Duration = DateTime.Now - connection.Started;
                SetPortStateWhenConnectionInterrupted(connection.Source, connection.Target);
            }
            else
                SetPortStateWhenConnectionInterrupted(connection.Source, default(PhoneNumber));

            this._connectionCollection.Remove(connection);
            AddCallInfo(connection);
        }
예제 #3
0
 protected virtual void OnCallInfoAdded(object sender, CallInfo e)
 {
     CallInfoAdded?.Invoke(sender, e);
 }
예제 #4
0
 protected void InterruptActiveCall(CallInfo connection)
 {
     connection.Duration = DateTime.Now - connection.Started;
     InterruptConnection(connection);
 }
예제 #5
0
        public void RegisterCall(Request request)
        {
            if (request.Source != default(PhoneNumber) && request.Target != default(PhoneNumber))
            {
                var sourceTerminal = GetTerminal(request.Source);
                var sourcePort = GetPort(sourceTerminal);

                var targetTerminal = GetTerminal(request.Target);
                var targetPort = GetPort(targetTerminal);

                var callInfo = new CallInfo()
                {
                    Source = request.Source,
                    Target = request.Target,
                    Started = DateTime.Now,
                    Duration = TimeSpan.Zero
                };

                var sourceConnection = GetLastConnectionInfo(request.Source);
                var targetConnection = GetLastConnectionInfo(request.Target);

                this._connectionCollection.Add(callInfo);

                if ((sourceConnection == null && targetConnection == null)
                    && (sourcePort.State != PortState.Off && targetPort.State != PortState.Off))
                {
                    sourcePort.State = PortState.Busy;
                    targetPort.State = PortState.Busy;

                    var incomingRequest = new Request(request.Source, request.Target, Request.IncomingCall);
                    targetTerminal.IncomingRequest(incomingRequest);
                }
                else
                {
                    InterruptConnection(callInfo);
                    Console.WriteLine("Drop");
                    sourceTerminal.IncomingRespond(new Respond(Respond.Drop, request));
                }
            }
        }
예제 #6
0
 public void AddCallInfo(CallInfo callInfo)
 {
     _callCollection.Add(callInfo);
     OnCallInfoAdded(this, callInfo);
 }
예제 #7
0
 protected void InterruptActiveCall(CallInfo connection)
 {
     connection.Duration = DateTime.Now - connection.Started;
     InterruptConnection(connection);
 }
예제 #8
0
 protected virtual void OnCallInfoAdded(object sender, CallInfo e)
 {
     CallInfoAdded?.Invoke(sender, e);
 }