public virtual bool IsTerminalState(int state, int moves, int maximumAllowedMoves) { bool result = TerminalStates.Contains(state % StatesPerPhase) || (maximumAllowedMoves > 0 && moves > maximumAllowedMoves); return(result); }
public void Connect() { if (Connecting != null) { State = TerminalStates.Connected; OnConnecting(this, null); } }
public void SetOnlineState(object sender, ICallingEventArgs e) { if (State == TerminalStates.OutgoingCall) { State = TerminalStates.Online; Console.WriteLine("Terminal {0}: online with terminal {1}.\n", this.Number, e.TargetNumber); } }
public void SetConnectedState(object sender, ICallingEventArgs e) { if (State == TerminalStates.OutgoingCall || State == TerminalStates.Online) { Console.WriteLine("Terminal {0}: call rejected.\n", this.Number); State = TerminalStates.Connected; } }
public void Reject() { if (State == TerminalStates.Online || State == TerminalStates.IncommingCall) { Console.WriteLine("Terminal {0}: reject call.\n", this.Number); State = TerminalStates.Connected; OnRejecting(); } }
public void SetIncommingCallState(object sender, ICallingEventArgs e) { Console.WriteLine("Terminal {0}: have incomming call from terminal {1}.\n", e.TargetNumber, e.SourceNumber); if (State == TerminalStates.Connected) { State = TerminalStates.IncommingCall; _e = e; } }
public virtual void AddTerminalState(int state) { if (TerminalStates == null) { TerminalStates = new List <int>(); } if (!TerminalStates.Contains(state)) { TerminalStates.Add(state); } }
public void Answer() { if (State == TerminalStates.IncommingCall) { Console.WriteLine("Terminal {0}: answer a call from terminal {1}.\n", this.Number, _e.SourceNumber); State = TerminalStates.Online; OnAnswering(); } else { Console.WriteLine("Terminal {0}: You need to call before you can answer the call.\n", this.Number); } }
public void Call(int targetNumber) { Console.WriteLine("\n"); if (State == TerminalStates.Connected) { if (targetNumber != this.Number) { State = TerminalStates.OutgoingCall; OnCalling(targetNumber); } else { Console.WriteLine("Terminal {0}: You are trying to call yourself!", this.Number); } } else { Console.WriteLine("Terminal {0}: please, connect me before calling!", this.Number); } }
public void Disconect() { State = TerminalStates.Disconnected; OnDisconnecting(this, null); }