new Channel()
Channel maintains the receiver collection for a subject. You can
add users into a channel and then broadcast message to them by channel.
Methods
-
add(uid, sid)
-
Add user to channel.
Parameters:
Name Type Description uid
Number user id sid
String frontend server id which user has connected to -
destroy()
-
Destroy channel.
-
getMember(uid) → {Object}
-
Get Member info.
Parameters:
Name Type Description uid
String user id Returns:
Object - member info -
getMembers() → {Array}
-
Get channel members. Notice: Heavy operation.
Returns:
Array - channel member uid list -
getUserAmount() → {number}
-
Get channel UserAmount in a channel.
Returns:
number - channel member amount -
leave(uid, sid)
-
Remove user from channel.
Parameters:
Name Type Description uid
Number user id sid
String frontend server id which user has connected to. Returns:
- [Boolean] true if success or false if fail -
pushMessage(route, msg, opts, cb)
-
Push message to all the members in the channel
Parameters:
Name Type Description route
String message route msg
Object message that would be sent to client opts
Object user-defined push options, optional cb
function callback function