Class: Jebanni::Server
- Inherits:
-
Reel::Server::HTTP
- Object
- Reel::Server::HTTP
- Jebanni::Server
- Includes:
- Celluloid::Logger
- Defined in:
- lib/jebanni/server.rb
Instance Method Summary collapse
- #all_connections ⇒ Object
- #broadcast_to(channel, data, event, id) ⇒ Object
- #channels ⇒ Object
-
#initialize(ip = '127.0.0.1', port = 63310) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(ip = '127.0.0.1', port = 63310) ⇒ Server
Returns a new instance of Server.
11 12 13 14 15 |
# File 'lib/jebanni/server.rb', line 11 def initialize(ip = '127.0.0.1', port = 63310) @channels = {} super(ip, port, &method(:on_connection)) async.ping end |
Instance Method Details
#all_connections ⇒ Object
28 29 30 |
# File 'lib/jebanni/server.rb', line 28 def all_connections @channels.map{|(_, channel)| channel.connections}.flatten end |
#broadcast_to(channel, data, event, id) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/jebanni/server.rb', line 17 def broadcast_to(channel, data, event, id) channel.connections.each do |socket| async.send_sse(socket, data, event, id) end true end |
#channels ⇒ Object
24 25 26 |
# File 'lib/jebanni/server.rb', line 24 def channels @channels end |