Exemplo n.º 1
0
 public override AState MoveState()
 {
     ClearCurrentEventHandlers();
     AState newState = new StateInitial();
     newState.MainView = _mainView;
     newState.ConversationControllers = _conversationControllers;
     ToCloseConnection = true;
     AMessageData messageData = new LogoutMessageData(this._userName);
     Common.Protocol.Message signoutMessage = new Common.Protocol.Message(new MessageHeader(ServiceTypes.LOGOUT), messageData);
     newState.OutputMessagesList.Add(signoutMessage);
     return newState;
 }
Exemplo n.º 2
0
 public override AState AnalyzeMessage(Common.Protocol.Message message)
 {
     AMessageData messageData = Common.Protocol.Message.GetMessageData(message);
     switch (message.Header.ServiceType)
     {
         case Common.ServiceTypes.PING:
             HandlePingMessage();
             break;
         case Common.ServiceTypes.TEXT:
             RedirectTextMessageToConversationController((TextMessageData)messageData);
             break;
         case Common.ServiceTypes.USER_CONNECTED:
             HandleUserConnectedMessage((UserConnectedMessageData)messageData);
             break;
         case Common.ServiceTypes.STATUS:
             HandleStatusMessage((StatusMessageData)messageData);
             break;
         case Common.ServiceTypes.USER_DISCONNECTED:
             HandleUserDisconnectedMessage((UserDisconnectedMessageData)messageData);
             break;
         case Common.ServiceTypes.CONNECTION_DATA:
             RedirectMessageToConversationController(message, ((ConnectionDataMessageData)messageData).Sender);
             break;
         case Common.ServiceTypes.CONNECTION_REQ:
             SendConnectionDataResponse((ConnectionDataRequestedMessageData)messageData);
             //RedirectMessageToConversationController(message, ((ConnectionDataRequestedMessageData)messageData).SenderUserName);
             break;
         case Common.ServiceTypes.DISCONNECT:
             AState newState = new StateInitial();
             newState.MainView = _mainView;
             newState.ToCloseConnection = true;
             newState.Disconected = true;
             newState.ConversationControllers = _conversationControllers;
             ErrorHandler.HandleError("You're not worthy! You have been signed out because you were logged in on another computer", "Warning", (IWin32Window)_mainView);
             return newState;
     }
     return this;
 }