lib/game_machine/handlers/request.rb in game_machine-0.0.11 vs lib/game_machine/handlers/request.rb in game_machine-1.0.2

- old
+ new

@@ -10,20 +10,18 @@ def on_receive(message) if message.is_a?(MessageLib::ClientMessage) if message.has_player_logout if Authentication.authenticated?(message.player) unregister_client(message) - commands.misc.player_status_change(message.player.id,:unregistered) end elsif message.has_player - update_entities(message) + update_entities(message) if Authentication.authenticated?(message.player) game_handler.tell(message) else if @auth_handler.authenticate!(message.player) register_client(message) - commands.misc.player_status_change(message.player.id,:registered) game_handler.tell(message) end end else unhandled(message) @@ -33,10 +31,18 @@ end end private + def update_entities(message) + if message.get_entity_list + message.get_entity_list.each do |entity| + entity.set_player(message.player) + end + end + end + def register_client(message) GameMachine.logger.info "Register #{message.player.id}" player_id = message.player.id client_id = message.client_connection.id #GameMachine.logger.info "player_id=#{message.player.id} client_id=#{client_id}" @@ -67,17 +73,9 @@ GameSystems::ChatManager.find.tell(chat_destroy) end def game_handler @game_handler ||= Handlers::Game.find - end - - def update_entities(message) - if message.get_entity_list - message.get_entity_list.each do |entity| - entity.set_player(message.player) - end - end end end end end