Class: ActionChannels::Server
- Inherits:
-
Object
- Object
- ActionChannels::Server
- Defined in:
- lib/action_channels/server.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #channel_repository ⇒ Object
-
#initialize(port:) ⇒ Server
constructor
A new instance of Server.
- #process_client(client) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(port:) ⇒ Server
Returns a new instance of Server.
7 8 9 |
# File 'lib/action_channels/server.rb', line 7 def initialize(port:) @port = port end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/action_channels/server.rb', line 5 def port @port end |
Instance Method Details
#channel_repository ⇒ Object
19 20 21 |
# File 'lib/action_channels/server.rb', line 19 def channel_repository @channel_repository ||= ChannelRepository.new end |
#process_client(client) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/action_channels/server.rb', line 23 def process_client(client) client.on :message, (client) client.on :close, callback_on_close(client) client end |
#run ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/action_channels/server.rb', line 11 def run NIO::WebSocket.listen port: port do |client| process_client client end ActionChannels.logger.info "Server started on port: #{port}" end |