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); }
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"); } }
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; } }
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"); } }
public void IncomingCall(object o, CallEventArgs call) { _ring = new System.Threading.Thread(() => { Ringing(call.InPhoneNumber); }); _ring.Start(); }