Class: GoldSrcServer

Inherits:
Object
  • Object
show all
Includes:
GameServer
Defined in:
lib/steam/servers/goldsrc_server.rb

Overview

This class represents a GoldSrc game server and can be used to query information about and remotely execute commands via RCON on the server

A GoldSrc game server is an instance of the Half-Life Dedicated Server (HLDS) running games using Valve’s GoldSrc engine, like Half-Life Deathmatch, Counter-Strike 1.6 or Team Fortress Classic.

See Also:

Author:

  • Sebastian Staudt

Constant Summary

Constants included from GameServer

GameServer::REQUEST_CHALLENGE, GameServer::REQUEST_INFO, GameServer::REQUEST_PLAYER, GameServer::REQUEST_RULES

Instance Attribute Summary

Attributes included from Server

#host_names, #ip_addresses

Instance Method Summary collapse

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_players, #update_rules, #update_server_info

Methods included from Server

#rotate_ip

Constructor Details

#initialize(address, port = 27015, is_hltv = false) ⇒ GoldSrcServer

Creates a new instance of a GoldSrc server object

Parameters:

  • address (String)

    Either an IP address, a DNS name or one of them combined with the port number. If a port number is given, e.g. ‘server.example.com:27016’ it will override the second argument.

  • port (Fixnum) (defaults to: 27015)

    The port the server is listening on

  • is_hltv (Boolean) (defaults to: false)

    HLTV servers need special treatment, so this is used to determine if the server is a HLTV server

Raises:



31
32
33
34
35
# File 'lib/steam/servers/goldsrc_server.rb', line 31

def initialize(address, port = 27015, is_hltv = false)
  super address, port

  @is_hltv = is_hltv
end

Instance Method Details

#init_socketObject

Initializes the socket to communicate with the GoldSrc server

See Also:



40
41
42
# File 'lib/steam/servers/goldsrc_server.rb', line 40

def init_socket
  @socket = GoldSrcSocket.new @ip_address, @port, @is_hltv
end

#rcon_auth(password) ⇒ true

Saves the password for authenticating the RCON communication with the server

Parameters:

  • password (String)

    The RCON password of the server

Returns:

  • (true)

    GoldSrc’s RCON does not preauthenticate connections so this method always returns ‘true`

See Also:



51
52
53
54
# File 'lib/steam/servers/goldsrc_server.rb', line 51

def rcon_auth(password)
  @rcon_password = password
  true
end

#rcon_exec(command) ⇒ String

Remotely executes a command on the server via RCON

Parameters:

  • command (String)

    The command to execute on the server via RCON

Returns:

  • (String)

    The output of the executed command

See Also:



61
62
63
# File 'lib/steam/servers/goldsrc_server.rb', line 61

def rcon_exec(command)
  @socket.rcon_exec(@rcon_password, command).strip
end