Exemple #1
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));
                }
            }
        }
Exemple #2
0
        protected void RegisterOutgoingRequest(object sender, Request request)
        {
            Console.WriteLine("Terminal connect to station");

            switch (request.Code)
            {
                case Request.OutcomingCall:
                    Console.WriteLine("call");
                    RegisterCall(request);

                    break;
                case Request.DisconnectCall:
                    Console.WriteLine("disconect call");
                    var connectInfoSource = GetLastConnectionInfo(request.Source);
                    if (connectInfoSource != null)
                        InterruptConnection(connectInfoSource);
                        //InterruptActiveCall(connectInfoSource);

                    break;
                default:
                    break;
            }
        }
Exemple #3
0
 public Respond(int code, Request request)
 {
     this.Code = code;
     this.Request = request;
 }