Class: SteamHldsLogParser::Client
- Inherits:
-
Object
- Object
- SteamHldsLogParser::Client
- Defined in:
- lib/steam_hlds_log_parser/client.rb
Overview
Listens to HLDS logs received via UDP on configured port
Instance Attribute Summary collapse
-
#displayer ⇒ Object
readonly
Returns the value of attribute displayer.
-
#options ⇒ Hash
readonly
Client options.
Instance Method Summary collapse
-
#initialize(displayer, options = {}) ⇒ Client
constructor
Creates a new client.
-
#start ⇒ Object
Starts the client which will receive HLDS logs (using UDP).
-
#stop ⇒ Object
Stops the client.
Constructor Details
#initialize(displayer, options = {}) ⇒ Client
Creates a new client
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/steam_hlds_log_parser/client.rb', line 29 def initialize(displayer, = {}) = { :host => "0.0.0.0", :port => 27115, :locale => :en, :display_end_map => true, :display_end_round => true, :display_kills => true, :display_actions => true, :display_changelevel => true, :display_chat => true, :display_team_chat => true, :display_connect => true, :display_disconnect => true } @options = .merge() @displayer = displayer end |
Instance Attribute Details
#displayer ⇒ Object (readonly)
Returns the value of attribute displayer.
9 10 11 |
# File 'lib/steam_hlds_log_parser/client.rb', line 9 def displayer @displayer end |
#options ⇒ Hash (readonly)
Client options
7 8 9 |
# File 'lib/steam_hlds_log_parser/client.rb', line 7 def @options end |
Instance Method Details
#start ⇒ Object
Starts the client which will receive HLDS logs (using UDP)
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/steam_hlds_log_parser/client.rb', line 49 def start # setting locale I18n.locale = @options[:locale] || I18n.default_locale EM.run { # catch CTRL+C Signal.trap("INT") { EM.stop } Signal.trap("TERM") { EM.stop } # Let's start EM::open_datagram_socket(@options[:host], @options[:port], Handler, @displayer, @options) } end |
#stop ⇒ Object
Stops the client
62 63 64 65 |
# File 'lib/steam_hlds_log_parser/client.rb', line 62 def stop puts "## #{@options[:host]}:#{@options[:port]} => #{I18n.t('client_stop')}" EM::stop_event_loop end |