class Source::RCON
Constants
- AuthenticationCommand
Attributes
host[RW]
port[RW]
Public Class Methods
new(host, port = 27015, password = nil)
click to toggle source
# File library/source/rcon.rb, line 12 def initialize host, port = 27015, password = nil @host, @port, @pass, @challenge = host, port, password, "" end
Public Instance Methods
authenticate()
click to toggle source
# File library/source/rcon.rb, line 41 def authenticate transmit AuthenticationCommand challenge = @socket.readpartial 1024 @challenge = challenge.gsub /[^\d+]/, "" end
authenticated?()
click to toggle source
# File library/source/rcon.rb, line 39 def authenticated?; @challenge end
connect()
click to toggle source
# File library/source/rcon.rb, line 18 def connect raise ConnectionError, "Connection has already been established" if connected? @socket = UDPSocket.new authenticate end
connected?()
click to toggle source
# File library/source/rcon.rb, line 16 def connected?; @socket and not @socket.closed? end
read()
click to toggle source
# File library/source/rcon.rb, line 31 def read @socket.readpartial 4096 end
send(command)
click to toggle source
# File library/source/rcon.rb, line 35 def send command transmit "rcon #{@challenge} \"#{@pass}\" #{command}" end
transmit(packet)
click to toggle source
# File library/source/rcon.rb, line 26 def transmit packet raise ConnectionError, 'Connection has not been established' unless connected? @socket.send "\xFF\xFF\xFF\xFF#{packet}", 0, @host, @port end