Class: Frostbitten::Client
- Inherits:
-
Object
- Object
- Frostbitten::Client
- Includes:
- Methods::AdminCommands, Methods::NormalCommands
- Defined in:
- lib/frostbitten/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Access to the server object.
Instance Method Summary collapse
-
#initialize(uri = nil, options = {}) ⇒ Client
constructor
Initialize class with URI ‘fbrcon://password@ip:port’ Also accept options { :keepalive = true/false, :socket_timeout => 1 } will setup connection object.
-
#send(commands) ⇒ Object
Will create Frostbitten::Header and Frostbitten::Message objects for given commands.
Methods included from Methods::NormalCommands
Methods included from Methods::AdminCommands
#ban_list, #events, #map_list, #reserved_slots_list
Constructor Details
#initialize(uri = nil, options = {}) ⇒ Client
Initialize class with URI ‘fbrcon://password@ip:port’ Also accept options { :keepalive = true/false, :socket_timeout => 1 } will setup connection object.
22 23 24 25 26 |
# File 'lib/frostbitten/client.rb', line 22 def initialize(uri=nil, ={}) if uri self.connection = Frostbitten::Connection.new(uri,) end end |
Instance Attribute Details
#connection ⇒ Object
Access to the server object.
16 17 18 |
# File 'lib/frostbitten/client.rb', line 16 def connection @connection end |
Instance Method Details
#send(commands) ⇒ Object
Will create Frostbitten::Header and Frostbitten::Message objects for given commands. Accepts either a string or a array of strings to send. Returns a list of words returned by server.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/frostbitten/client.rb', line 32 def send(commands) return unless self.connection if commands.is_a? String commands = [commands] end header = Frostbitten::Header.new(:origin => :client, :response => false) msg = Frostbitten::Message.new(:words => commands, :header => header) = connection.send(msg) return .words[1..-1] end |