Class: Rubycon::RconExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycon/rcon_executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_info, command) ⇒ RconExecutor

Returns a new instance of RconExecutor.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rubycon/rcon_executor.rb', line 4

def initialize(server_info, command)
  begin
    @commands = []
    @server_info = server_info
    @session = SourceServer.new @server_info.address, @server_info.port
    @session.rcon_auth(@server_info.rcon)
    @response = rcon_exec command
  rescue RCONNoAuthError
    @response = 'Could not authenticate with gameserver. Wrong rcon password?'
  rescue Errno::ECONNREFUSED
    @response = 'Connection refused. Wrong host?'
  rescue SteamCondenser::TimeoutError
    @response = 'Connection timed out while sending command!'
  rescue Exception => e
    @response = "#{e.message}"
  end
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/rubycon/rcon_executor.rb', line 3

def response
  @response
end