コード例 #1
0
ファイル: Port.cs プロジェクト: ArseniBarsegyan/EPAM_training
        //Methods-handlers of Server events

        protected virtual void ServerOnUserIsUnavaliable(object sender, string message)
        {
            if (sender as Port != this)
            {
                return;
            }
            State = PortState.Enabled;
            UserIsUnavaliable?.Invoke(sender, message);
            PortEnabled?.Invoke(this, EventArgs.Empty);
        }
コード例 #2
0
 private void CheckActivePortCalledNumber(Port port, int callNumber)
 {
     if (IsDisableListContainsCalledNumber(callNumber))
     {
         UserIsUnavaliable?.Invoke(port, "User is unavaliable now. Please try again.");
     }
     else if (IsActiveListContainsCalledNumber(callNumber))
     {
         UserIsBusy?.Invoke(port, "User is busy. Please try again later.");
     }
     else if (IsEnabledListContainsCalledNumber(callNumber))
     {
         var port2 = EnabledPorts.FirstOrDefault(x => x.Number == callNumber);
         if (port2 != null)
         {
             EstablishConnection?.Invoke(this, new ConnectionEventArgs(port, port2));
         }
     }
     else
     {
         UserDoesntExists?.Invoke(port, "We're sorry, but user with this number doesn't exists.");
     }
 }