Beispiel #1
0
 public void AddCallInfo(CallInfo callInfo)
 {
     _callCollection.Add(callInfo);
     OnCallInfoAdded(this, callInfo);
 }
Beispiel #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);
        }
Beispiel #3
0
 protected virtual void OnCallInfoAdded(object sender, CallInfo e)
 {
     CallInfoAdded?.Invoke(sender, e);
 }
Beispiel #4
0
 protected void InterruptActiveCall(CallInfo connection)
 {
     connection.Duration = DateTime.Now - connection.Started;
     InterruptConnection(connection);
 }
Beispiel #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));
                }
            }
        }
Beispiel #6
0
 public void AddCallInfo(CallInfo callInfo)
 {
     _callCollection.Add(callInfo);
     OnCallInfoAdded(this, callInfo);
 }
Beispiel #7
0
 protected void InterruptActiveCall(CallInfo connection)
 {
     connection.Duration = DateTime.Now - connection.Started;
     InterruptConnection(connection);
 }
Beispiel #8
0
 protected virtual void OnCallInfoAdded(object sender, CallInfo e)
 {
     CallInfoAdded?.Invoke(sender, e);
 }