class Citrus::Common::Remote::Frontend::ChannelRemote
Public Class Methods
new(app)
click to toggle source
Create a new remote channel service
@param [Object] app
# File lib/citrus/common/remote/frontend/channel_remote.rb, line 25 def initialize app @app = app end
Public Instance Methods
broadcast(route, msg, args, &block)
click to toggle source
Broadcast to all the clients connected with current frontend server
@param [String] route @param [Hash] msg @param [Hash] args
# File lib/citrus/common/remote/frontend/channel_remote.rb, line 65 def broadcast route, msg, args, &block connector = @app.components['connector'] connector.send nil, route, msg, nil, args, &block end
pushMessage(route, msg, uids, args) { |exception 'can not send empty message'| ... }
click to toggle source
Push message to client by uids
@param [String] route @param [Hash] msg @param [Array] uids @param [Hash] args
# File lib/citrus/common/remote/frontend/channel_remote.rb, line 35 def pushMessage route, msg, uids, args, &block if msg.empty? block_given? and yield Exception.new 'can not send empty message' return end connector = @app.components['connector'] session_service = @app.session_service sids = []; fails = [] uids.each { |uid| sessions = session_service.get_by_uid uid if sessions sessions.each { |session| sids << session.id } else fails << uid end } connector.send(nil, route, msg, sids, args) { |err| block_given? and yield err, fails } end