Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SessionComponent

Session component. Manage sessions.

param

current application context

param

attach parameters

Hierarchy

Implements

Index

Constructors

constructor

Properties

abind

abind: function = utils.promisify(this.bind)

Type declaration

    • (sid: SID, uid: UID): Promise<void>
    • Parameters

      Returns Promise<void>

aimport

aimport: function = utils.promisify(this.import)

Type declaration

    • (sid: SID, key: string, value: any): Promise<void>
    • Parameters

      • sid: SID
      • key: string
      • value: any

      Returns Promise<void>

aimportAll

aimportAll: function = utils.promisify(this.importAll)

Type declaration

    • (sid: SID, settings: any): Promise<void>
    • Parameters

      • sid: SID
      • settings: any

      Returns Promise<void>

akick

akick: function = utils.promisify(this.kick)

Type declaration

    • (uid: UID, reason?: string): Promise<void>
    • Parameters

      • uid: UID
      • Optional reason: string

      Returns Promise<void>

akickBySessionId

akickBySessionId: function = utils.promisify(this.kickBySessionId)

Type declaration

    • (sid: SID, reason?: string): Promise<void>
    • Parameters

      • sid: SID
      • Optional reason: string

      Returns Promise<void>

app

aunbind

aunbind: function = utils.promisify(this.unbind)

Type declaration

    • (sid: SID, uid: UID): Promise<void>
    • Parameters

      Returns Promise<void>

name

name: string = "__session__"

sessions

sessions: object

Type declaration

singleSession

singleSession: Session

uidMap

uidMap: object

Type declaration

Methods

bind

  • bind(sid: SID, uid: UID, cb: function): void
  • Bind the session with a user id.

    memberof

    SessionService

    api

    private

    Parameters

    • sid: SID
    • uid: UID
    • cb: function
        • (err: Error | null, result?: void): void
        • Parameters

          • err: Error | null
          • Optional result: void

          Returns void

    Returns void

create

forEachBindedSession

  • forEachBindedSession(cb: function): void

forEachSession

  • forEachSession(cb: function): void

get

getByUid

getClientAddressBySessionId

  • getClientAddressBySessionId(sid: SID): any

getSessionsCount

  • getSessionsCount(): number

import

  • import(sid: SID, key: string, value: string, cb: function): void
  • Import the key/value into session.

    api

    private

    Parameters

    • sid: SID
    • key: string
    • value: string
    • cb: function
        • (err?: Error, result?: void): void
        • Parameters

          • Optional err: Error
          • Optional result: void

          Returns void

    Returns void

importAll

  • importAll(sid: SID, settings: object, cb: function): void
  • Import new value for the existed session.

    memberof

    SessionService

    api

    private

    Parameters

    • sid: SID
    • settings: object
      • [key: string]: any
    • cb: function
        • (err?: Error, result?: void): void
        • Parameters

          • Optional err: Error
          • Optional result: void

          Returns void

    Returns void

kick

  • kick(uid: UID, reason?: string, cb?: function): void
  • Kick all the session offline under the user id.

    memberof

    SessionService

    Parameters

    • uid: UID

      user id asscociated with the session

    • Optional reason: string
    • Optional cb: function

      callback function

        • (err?: Error, result?: void): void
        • Parameters

          • Optional err: Error
          • Optional result: void

          Returns void

    Returns void

kickBySessionId

  • kickBySessionId(sid: SID, reason?: string, cb?: function): void
  • Kick a user offline by session id.

    memberof

    SessionService

    Parameters

    • sid: SID

      session id

    • Optional reason: string
    • Optional cb: function

      callback function

        • (err?: Error, result?: void): void
        • Parameters

          • Optional err: Error
          • Optional result: void

          Returns void

    Returns void

remove

  • remove(sid: SID): void

sendMessage

  • sendMessage(sid: SID, msg: any): boolean

sendMessageByUid

  • sendMessageByUid(uid: UID, msg: any): boolean

unbind

  • unbind(sid: SID, uid: UID, cb: function): void
  • Unbind a session with the user id.

    memberof

    SessionService

    api

    private

    Parameters

    • sid: SID
    • uid: UID
    • cb: function
        • (err?: Error, result?: void): void
        • Parameters

          • Optional err: Error
          • Optional result: void

          Returns void

    Returns void