Beispiel #1
0
        private Enums.Mode SetConnection(CallEventArgs call)
        {
            Port portOut = Ports.FirstOrDefault(x => x.PhoneNumber == call.OutPhoneNumber);

            if (portOut == null)
            {
                return(Enums.Mode.NotExist);
            }
            Port portIn = Ports.First(x => x.PhoneNumber == call.InPhoneNumber);

            Enums.Mode modePort = portOut.Mode;
            if (modePort == Enums.Mode.Free)
            {
                if (!ActiveConnections.ContainsKey(call.InPhoneNumber))
                {
                    GetStation().TerminalAnswered   += portIn.OutCallAnswered;
                    GetStation().TerminalNoAnswered += portIn.OutCallNoAnswered;
                    GetStation().TerminalRejected   += portIn.OutCallRejected;
                    ActiveConnections.Add(call.InPhoneNumber, call.OutPhoneNumber);
                    portOut.Mode           = Enums.Mode.Ringing;
                    portIn.Mode            = Enums.Mode.Ringing;
                    portOut.AnswerEvent   += AnsweredCall;
                    portOut.RejectEvent   += RejectedCall;
                    portOut.NoAnswerEvent += NoAnsweredCall;
                    portOut.IncomingCall(call.InPhoneNumber);
                }
            }
            if (modePort == Enums.Mode.Ringing)
            {
                return(Enums.Mode.Busy);
            }
            return(modePort);
        }
Beispiel #2
0
 public void OutCallRejected(object o, CallEventArgs e)
 {
     if (e.InPhoneNumber == PhoneNumber)
     {
         Mode = Enums.Mode.Free;
         ATS.GetStation().TerminalAnswered   -= OutCallAnswered;
         ATS.GetStation().TerminalNoAnswered -= OutCallNoAnswered;
         ATS.GetStation().TerminalRejected   -= OutCallRejected;
         Console.WriteLine("Call rejected");
     }
 }
Beispiel #3
0
 public void OutCallAnswered(object o, CallEventArgs e)
 {
     if (e.InPhoneNumber == PhoneNumber)
     {
         Mode = Enums.Mode.Busy;
         ATS.GetStation().TerminalAnswered   -= OutCallAnswered;
         ATS.GetStation().TerminalNoAnswered -= OutCallNoAnswered;
         ATS.GetStation().TerminalRejected   -= OutCallRejected;
         ATS.GetStation().EndCallEvent       += EndCallOnPort;
         Console.WriteLine("Call are accepted");
         Terminal.EndCallEvent += EndCallOnPort;
     }
 }
Beispiel #4
0
        public Enums.Mode OnTerminalCall(CallEventArgs call)
        {
            switch (Mode)
            {
            case Enums.Mode.Blocked: { return(Enums.Mode.Blocked); }

            case Enums.Mode.Busy: { return(Enums.Mode.Busy); }

            case Enums.Mode.Ringing: { return(Enums.Mode.Ringing); }

            case Enums.Mode.Free:
            {
                return(SetConnection(call));
            }

            default: throw new Exception("Call error");
            }
        }
Beispiel #5
0
 public void IncomingCall(object o, CallEventArgs call)
 {
     _ring = new System.Threading.Thread(() => { Ringing(call.InPhoneNumber); });
     _ring.Start();
 }