Class: Flamethrower::EventServer
- Inherits:
-
Object
- Object
- Flamethrower::EventServer
- Defined in:
- lib/flamethrower/server/event_server.rb
Constant Summary collapse
- ASCII_DEFAULTS =
{ 'enabled' => true }
Instance Attribute Summary collapse
-
#ascii_conversion ⇒ Object
readonly
Returns the value of attribute ascii_conversion.
-
#campfire_connection ⇒ Object
readonly
Returns the value of attribute campfire_connection.
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ EventServer
constructor
A new instance of EventServer.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ EventServer
Returns a new instance of EventServer.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/flamethrower/server/event_server.rb', line 30 def initialize( = {}) @host = ['host'] || "0.0.0.0" @port = ['port'] || 6667 @domain = ['domain'] @token = ['token'] @ascii_conversion = ['ascii_conversion'] ? ASCII_DEFAULTS.merge(['ascii_conversion']) : ASCII_DEFAULTS @connections = [] end |
Instance Attribute Details
#ascii_conversion ⇒ Object (readonly)
Returns the value of attribute ascii_conversion.
25 26 27 |
# File 'lib/flamethrower/server/event_server.rb', line 25 def ascii_conversion @ascii_conversion end |
#campfire_connection ⇒ Object (readonly)
Returns the value of attribute campfire_connection.
25 26 27 |
# File 'lib/flamethrower/server/event_server.rb', line 25 def campfire_connection @campfire_connection end |
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
25 26 27 |
# File 'lib/flamethrower/server/event_server.rb', line 25 def connections @connections end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
25 26 27 |
# File 'lib/flamethrower/server/event_server.rb', line 25 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
25 26 27 |
# File 'lib/flamethrower/server/event_server.rb', line 25 def port @port end |
Instance Method Details
#start ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/flamethrower/server/event_server.rb', line 41 def start EventMachine::run do FLAMETHROWER_LOGGER.info "Flamethrower started at #{@host}:#{@port} on domain #{@domain}" @signature = EventMachine::start_server(@host, @port, EventConnection) do |connection| @connections << connection connection.server = self connection.campfire_connection = Flamethrower::Campfire::Connection.new(@domain, @token, connection) end end end |
#stop ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/flamethrower/server/event_server.rb', line 52 def stop FLAMETHROWER_LOGGER.info("Killing room threads") @connections.each do |connection| connection.stop connection.close_connection end EventMachine.stop_server(@signature) EventMachine.add_periodic_timer(0.2) { die_safely } end |