Class: Jebanni::Server

Inherits:
Reel::Server::HTTP
  • Object
show all
Includes:
Celluloid::Logger
Defined in:
lib/jebanni/server.rb

Instance Method Summary collapse

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_connectionsObject



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

#channelsObject



24
25
26
# File 'lib/jebanni/server.rb', line 24

def channels
  @channels
end