Skip to content

i_en_session

huangjizhong edited this page Dec 1, 2021 · 1 revision

Session类

uid

readonly uid: number

  • binded uid

sid

readonly sid: string

  • frontend server id

set()

set(value: { [key: string]: any }): void

  • Set key-value pairs
  • Corresponding to get(), delete(), the modification of the frontend server call will be reflected in the backend server, but the modification of the backend server call will only change temporarily. Because the session of the backend server is a copy of each message forwarded by the frontend server.

get()

get<T = any>(key: number | string): T

  • Get key-value pairs

delete()

delete(keys: (number | string)[]): void

  • Delete key-value pair

setLocal()

setLocal(key: number | string, value: any): void

  • Set key-value pairs (local)
  • Corresponding to getLocal(), deleteLocal(), the modification of the frontend server call will not be reflected to the backend server. The backend service call modification will only change temporarily.

getLocal()

getLocal<T = any>(key: number | string): T

  • Get key-value pairs (local)

deleteLocal()

deleteLocal(key: number | string): void

  • Delete key-value pair (local)

bind()

bind(uid: number): boolean

  • Bind uid (frontend server call)

close()

close(): void

  • Close connection (frontend server call)

apply()

apply(): void

  • Synchronize the backend session to the frontend (backend server call)

getIp()

getIp(): string

  • Get ip (frontend server call)

send()

send(cmd: number, msg: any): void

  • Send msg to client (frontend server call)