Class: Q2ServerQuery::Client
- Inherits:
-
Object
- Object
- Q2ServerQuery::Client
- Defined in:
- lib/q2_server_query/client.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
-
#players_list ⇒ Object
readonly
Returns the value of attribute players_list.
-
#port ⇒ Object
Returns the value of attribute port.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
-
#initialize(address, port) ⇒ Client
constructor
A new instance of Client.
- #status ⇒ Object
Constructor Details
#initialize(address, port) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 |
# File 'lib/q2_server_query/client.rb', line 9 def initialize(address, port) @socket = UDPSocket.new @timeout = 2 @address = address @port = port @msg = "\xff\xff\xff\xffstatus\x00" end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
6 7 8 |
# File 'lib/q2_server_query/client.rb', line 6 def address @address end |
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
7 8 9 |
# File 'lib/q2_server_query/client.rb', line 7 def parsed_response @parsed_response end |
#players_list ⇒ Object (readonly)
Returns the value of attribute players_list.
7 8 9 |
# File 'lib/q2_server_query/client.rb', line 7 def players_list @players_list end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/q2_server_query/client.rb', line 6 def port @port end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
7 8 9 |
# File 'lib/q2_server_query/client.rb', line 7 def raw_response @raw_response end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
7 8 9 |
# File 'lib/q2_server_query/client.rb', line 7 def socket @socket end |
Instance Method Details
#status ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/q2_server_query/client.rb', line 17 def status response = status_query return nil if response.nil? @parsed_response = response.first.split("\\") response_header = @parsed_response.shift[4..8] return if response_header != "print" build_status(@parsed_response) end |