new ChannelService()
Create and maintain channels for server local.
ChannelService is created by channel component which is a default loaded
component of pomelo and channel service would be accessed by `app.get('channelService')`.
Methods
-
broadcast(stype, route, msg, opts, cb)
-
Broadcast message to all the connected clients.
Parameters:
Name Type Description stype
String frontend server type string route
String route string msg
Object message opts
Object user-defined broadcast options, optional opts.binded: push to binded sessions or all the sessions opts.filterParam: parameters for broadcast filter. cb
function callback -
createChannel(name)
-
Create channel with name.
Parameters:
Name Type Description name
String channel's name -
destroyChannel(name)
-
Destroy channel by name.
Parameters:
Name Type Description name
String channel name -
getChannel(name, create) → {Channel}
-
Get channel by name.
Parameters:
Name Type Description name
String channel's name create
Boolean if true, create channel Returns:
Channel -
pushMessageByUids(route, msg, uids, opts, cb)
-
Push message by uids. Group the uids by group. ignore any uid if sid not specified.
Parameters:
Name Type Description route
String message route msg
Object message that would be sent to client uids
Array the receiver info list, [{uid: userId, sid: frontendServerId}] opts
Object user-defined push options, optional cb
function cb(err)