Exemplo n.º 1
0
        public virtual bool IsTerminalState(int state, int moves, int maximumAllowedMoves)
        {
            bool result = TerminalStates.Contains(state % StatesPerPhase) ||
                          (maximumAllowedMoves > 0 && moves > maximumAllowedMoves);

            return(result);
        }
Exemplo n.º 2
0
 public void Connect()
 {
     if (Connecting != null)
     {
         State = TerminalStates.Connected;
         OnConnecting(this, null);
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
        public void Reject()
        {
            if (State == TerminalStates.Online || State == TerminalStates.IncommingCall)
            {
                Console.WriteLine("Terminal {0}: reject call.\n", this.Number);

                State = TerminalStates.Connected;
                OnRejecting();
            }
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
        public virtual void AddTerminalState(int state)
        {
            if (TerminalStates == null)
            {
                TerminalStates = new List <int>();
            }

            if (!TerminalStates.Contains(state))
            {
                TerminalStates.Add(state);
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 public void Disconect()
 {
     State = TerminalStates.Disconnected;
     OnDisconnecting(this, null);
 }