Class: GameMachine::Endpoints::UdpOutgoing
- Inherits:
-
Actor::Base
- Object
- JavaLib::GameActor
- Actor::Base
- GameMachine::Endpoints::UdpOutgoing
- Defined in:
- lib/game_machine/endpoints/udp_outgoing.rb
Constant Summary
Constants inherited from Actor::Base
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#client_connection ⇒ Object
readonly
Returns the value of attribute client_connection.
-
#player_id ⇒ Object
readonly
Returns the value of attribute player_id.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #create_client_message ⇒ Object
- #on_receive(message) ⇒ Object
- #post_init(*args) ⇒ Object
- #send_connected_message ⇒ Object
- #send_to_client(message) ⇒ Object
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 Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 5 def client @client end |
#client_connection ⇒ Object (readonly)
Returns the value of attribute client_connection.
5 6 7 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 5 def client_connection @client_connection end |
#player_id ⇒ Object (readonly)
Returns the value of attribute player_id.
5 6 7 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 5 def player_id @player_id end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 5 def protocol @protocol end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
5 6 7 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 5 def server @server end |
Instance Method Details
#create_client_message ⇒ Object
22 23 24 25 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 22 def = MessageLib::ClientMessage.new .set_client_connection(client_connection) end |
#on_receive(message) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 43 def on_receive() #GameMachine.logger.info "Sending message to player" = .set_send_to_player(false) .add_entity() send_to_client() end |
#post_init(*args) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 6 def post_init(*args) @client_connection = args[0] @client = args[1] @server = args[2] @player_id = args[3] @protocol = args[4] GameMachine.logger.info "Player gateway created #{player_id}" end |
#send_connected_message ⇒ Object
16 17 18 19 20 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 16 def = .set_player_connected(MessageLib::PlayerConnected.new) send_to_client() end |
#send_to_client(message) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/game_machine/endpoints/udp_outgoing.rb', line 27 def send_to_client() #GameMachine.logger.info("Sending #{message} out via #{protocol}") if protocol == 0 bytes = .to_byte_array server.sendToClient( client[:address], bytes, client[:ctx] ) else client[:ctx].write() client[:ctx].flush JavaLib::UdpServerHandler.countOut.incrementAndGet end end |