Ejemplo n.º 1
0
 def _on_player_response(self, message):
     '''
     Рассылает сообщение, что пользователь получает ответ.
     @param message: PlayerResponseMessage
     '''
     logger.debug('sending user response message')
     player = message.player
     new_message = messages.UserResponseMessage(player.user, player.connection_id, message.packet)
     user_dispatcher.dispatch(new_message)
Ejemplo n.º 2
0
 def _on_client_request(self, message):
     '''
     Выполняется при запросе от клиента.
     @param message: ClientRequestMessage
     '''
     connection_id = message.connection_id
     if connection_id in self._authenticated:
         user = self._authenticated[connection_id]
         new_message = messages.UserRequestMessage(user, connection_id, message.packet)
         user_dispatcher.dispatch(new_message)
Ejemplo n.º 3
0
 def _on_client_disconnected(self, message):
     '''
     Выполняется при отключении клиента.
     @param message: ClientDisconnectedMessage
     '''
     connection_id = message.connection_id
     if connection_id in self._authenticated:
         user = self._authenticated[connection_id]
         logger.debug('user %s log out'%user)
         new_message = messages.UserDisconnectedMessage(user, connection_id)
         user_dispatcher.dispatch(new_message)
Ejemplo n.º 4
0
 def _authenticate(self, connection_id, login, password):
     '''
     Аутентифицирует пользователя.
     @param connection_id: int
     @param login: string
     @param password: string
     '''
     user = UserProcessor.get_by_login_and_password(login, password)
     if user is None:
         logger.debug('user with login "%s" not found'%login)
         status = outcoming.LoginStatusPacket.STATUS_NOT_FOUND
     else:
         logger.debug('user %s successfully authenticated'%user)
         self._authenticated[connection_id] = user
         status = outcoming.LoginStatusPacket.STATUS_OK
     packet = outcoming.LoginStatusPacket(status)
     message = messages.UserResponseMessage(user, connection_id, packet)
     user_dispatcher.dispatch(message)