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 stypeString frontend server type string routeString route string msgObject message optsObject user-defined broadcast options, optional opts.binded: push to binded sessions or all the sessions opts.filterParam: parameters for broadcast filter. cbfunction callback -
createChannel(name)
-
Create channel with name.
Parameters:
Name Type Description nameString channel's name -
destroyChannel(name)
-
Destroy channel by name.
Parameters:
Name Type Description nameString channel name -
getChannel(name, create) → {Channel}
-
Get channel by name.
Parameters:
Name Type Description nameString channel's name createBoolean 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 routeString message route msgObject message that would be sent to client uidsArray the receiver info list, [{uid: userId, sid: frontendServerId}] optsObject user-defined push options, optional cbfunction cb(err)