Class: ActionChannels::Server
- Inherits:
-
Object
- Object
- ActionChannels::Server
- Defined in:
- lib/action_channels/server.rb
Instance Attribute Summary collapse
-
#channel_repository ⇒ Object
readonly
Returns the value of attribute channel_repository.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(options) ⇒ Server
constructor
A new instance of Server.
- #process_client(client) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Server
Returns a new instance of Server.
5 6 7 8 |
# File 'lib/action_channels/server.rb', line 5 def initialize() @port = .fetch(:port) @channel_repository = ChannelRepository.new .fetch(:channels, []) end |
Instance Attribute Details
#channel_repository ⇒ Object (readonly)
Returns the value of attribute channel_repository.
3 4 5 |
# File 'lib/action_channels/server.rb', line 3 def channel_repository @channel_repository end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/action_channels/server.rb', line 3 def port @port end |
Instance Method Details
#process_client(client) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/action_channels/server.rb', line 18 def process_client(client) client.on :message, (client) client.on :close, callback_on_close(client) client.on :error, callback_on_error(client) client.on :io_error, callback_on_io_error(client) client end |
#run ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/action_channels/server.rb', line 10 def run NIO::WebSocket.listen port: port do |driver| process_client Driver.new(driver) end ActionChannels.logger.info "Server started on port: #{port}" end |