BackendSessionService()

new BackendSessionService()

Service that maintains backend sessions and the communication with frontend servers. BackendSessionService would be created in each server process and maintains backend sessions for current process and communicates with the relative frontend servers. BackendSessionService instance could be accessed by `app.get('backendSessionService')` or app.backendSessionService.

Methods

bind(frontendId, sid, uid, cb)

Bind the session with the specified user id. It would finally invoke the the sessionService.bind in the cooperating frontend server.
Parameters:
Name Type Description
frontendId String cooperating frontend server id
sid Number session id
uid String user id
cb function callback function

get(frontendId, sid, cb)

Get backend session by frontend server id and session id.
Parameters:
Name Type Description
frontendId String frontend server id that session attached
sid String session id
cb function callback function. args: cb(err, BackendSession)

getByUid(frontendId, uid, cb)

Get backend sessions by frontend server id and user id.
Parameters:
Name Type Description
frontendId String frontend server id that session attached
uid String user id binded with the session
cb function callback function. args: cb(err, BackendSessions)

kickBySid(frontendId, sid, cb)

Kick a session by session id.
Parameters:
Name Type Description
frontendId String cooperating frontend server id
sid Number session id
cb function callback function

kickByUid(frontendId, uid, reason, cb)

Kick sessions by user id.
Parameters:
Name Type Description
frontendId String cooperating frontend server id
uid Number | String user id
reason String kick reason
cb function callback function

push(frontendId, sid, key, value, cb)

Push the specified customized change to the frontend internal session.
Parameters:
Name Type Description
frontendId String cooperating frontend server id
sid Number session id
key String key in session that should be push
value Object value in session, primitive js object
cb function callback function

pushAll(frontendId, sid, settings, cb)

Push all the customized changes to the frontend internal session.
Parameters:
Name Type Description
frontendId String cooperating frontend server id
sid Number session id
settings Object key/values in session that should be push
cb function callback function

unbind(frontendId, sid, uid, cb)

Unbind the session with the specified user id. It would finally invoke the the sessionService.unbind in the cooperating frontend server.
Parameters:
Name Type Description
frontendId String cooperating frontend server id
sid Number session id
uid String user id
cb function callback function