Class: SourceServer
- Inherits:
-
Object
- Object
- SourceServer
- Includes:
- GameServer
- Defined in:
- lib/steam/servers/source_server.rb
Constant Summary
Constants included from GameServer
GameServer::REQUEST_CHALLENGE, GameServer::REQUEST_INFO, GameServer::REQUEST_PLAYER, GameServer::REQUEST_RULES
Instance Method Summary collapse
-
#init_socket ⇒ Object
Initializes the sockets to communicate with the Source server.
-
#initialize(address, port = 27015) ⇒ SourceServer
constructor
A new instance of SourceServer.
- #rcon_auth(password) ⇒ Object
- #rcon_exec(command) ⇒ Object
Methods included from GameServer
#handle_response_for_request, #init, #ping, player_status_attributes, #players, #rcon_authenticated?, #rules, #server_info, split_player_status, #to_s, #update_challenge_number, #update_ping, #update_player_info, #update_rules_info, #update_server_info
Methods included from Server
Constructor Details
#initialize(address, port = 27015) ⇒ SourceServer
Returns a new instance of SourceServer.
19 20 21 |
# File 'lib/steam/servers/source_server.rb', line 19 def initialize(address, port = 27015) super end |
Instance Method Details
#init_socket ⇒ Object
Initializes the sockets to communicate with the Source server
24 25 26 27 |
# File 'lib/steam/servers/source_server.rb', line 24 def init_socket @rcon_socket = RCONSocket.new @ip_address, @port @socket = SourceSocket.new @ip_address, @port end |
#rcon_auth(password) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/steam/servers/source_server.rb', line 29 def rcon_auth(password) @rcon_request_id = rand 2**16 @rcon_socket.send RCONAuthRequest.new(@rcon_request_id, password) @rcon_socket.reply reply = @rcon_socket.reply raise RCONNoAuthException.new if reply.request_id == -1 reply.request_id == @rcon_request_id end |
#rcon_exec(command) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/steam/servers/source_server.rb', line 41 def rcon_exec(command) @rcon_socket.send RCONExecRequest.new(@rcon_request_id, command) @rcon_socket.send RCONTerminator.new(@rcon_request_id) response_packets = [] begin response_packet = @rcon_socket.reply redo if response_packet.nil? raise RCONNoAuthException.new if response_packet.is_a? RCONAuthResponse response_packets << response_packet end while response_packet.response.size > 0 response = '' response_packets.each do |packet| response << packet.response end response.strip end |