Class: GameMachine::GameSystems::ChatManager
- Inherits:
-
Actor::Base
- Object
- JavaLib::GameActor
- Actor::Base
- GameMachine::GameSystems::ChatManager
- Includes:
- Commands
- Defined in:
- lib/game_machine/game_systems/chat_manager.rb
Overview
Note:
All chat system requests go through the ChatManager Chat can be topic based or private player to player messages Topics are automatically created by the first player to send a join request to a topic that does not already exist.
Chat topic channels are distributed across the cluster, and guaranteed to be delivered.
Constant Summary
Constants inherited from Actor::Base
Instance Method Summary collapse
Methods included from Commands
Methods inherited from Actor::Base
aspect, aspects, find, find_by_address, find_distributed, find_distributed_local, find_remote, hashring, local_path, model_filter, #onReceive, player_controller, #receive_message, #schedule_message, #sender, set_player_controller
Instance Method Details
#define_update_procs ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/game_machine/game_systems/chat_manager.rb', line 24 def define_update_procs commands.datastore.define_dbproc(:chat_remove_subscriber) do |id,current_entity,update_entity| if current_entity.nil? current_entity = MessageLib::Entity.new.set_id(id) end if current_entity.has_subscribers if subscriber_id_list = current_entity.subscribers.get_subscriber_id_list.to_a current_entity.subscribers.set_subscriber_id_list(nil) subscriber_id_list.each do |name| unless name == update_entity.id current_entity.subscribers.add_subscriber_id(name) end end end end current_entity end commands.datastore.define_dbproc(:chat_add_subscriber) do |id,current_entity,update_entity| if current_entity.nil? current_entity = MessageLib::Entity.new.set_id(id) end unless current_entity.has_subscribers current_entity.set_subscribers(MessageLib::Subscribers.new) end subscriber_id_list = current_entity.subscribers.get_subscriber_id_list.to_a unless subscriber_id_list.include?(update_entity.id) current_entity.subscribers.add_subscriber_id(update_entity.id) end current_entity end end |
#on_receive(message) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/game_machine/game_systems/chat_manager.rb', line 65 def on_receive() if .is_a?(MessageLib::ChatDestroy) if @chat_actors.has_key?(.player_id) ask_child(.player_id,) destroy_child(.player_id) end return end if .has_chat_invite send_invite(.chat_invite) elsif .has_chat_register unless @chat_actors.has_key?(.chat_register.chat_id) create_child(.chat_register.chat_id,.chat_register.register_as) end else unless @chat_actors.has_key?(.player.id) create_child(.player.id) end forward_chat_request(.player.id,) end end |
#post_init(*args) ⇒ Object
60 61 62 63 |
# File 'lib/game_machine/game_systems/chat_manager.rb', line 60 def post_init(*args) @chat_actors = {} define_update_procs end |