Users.Socket Class
Replacements for Q.Socket methods, use these instead. They implement logic involving sockets, users, sessions, devices, and more.
Methods
appId
(
Object
static
-
platform
-
appId
Get the internal app id and info
Parameters:
Returns:
Object:
Has keys "appId" and "appInfo"
emitToUser
(
Boolean
static
-
userId
-
event
-
data
-
excludeSessionIds={}
Emits an event to user's socket.io clients that are currently connected
Parameters:
Returns:
Boolean:
Whether any socket clients were connected at all
listen
(
socket.io
-
options
Start http server if needed, and start listening to socket. Use this instead of Users.socket This also attaches a few event handlers for Users events.
Parameters:
Returns:
socket.io:
Events
connected
User has connected. Reconnections before disconnect timeout don't count.
Event Payload:
-
client
SocketThe connecting client. Contains userId, sessionId, clientId
-
online
BooleanWhether any other clients were online for the user before this
disconnected
User has disconnected, and timeout for reconnection has passed
Event Payload:
-
userId
Stringid of the user that disconnected