UNPKG

sdg

Version:

pomelo ts

48 lines (47 loc) 1.43 kB
/// <reference types="node" /> import { EventEmitter } from "events"; import SessionService from '../sessionService'; import { FRONTEND_ID, IConnectorSocket, IMsgRspEncode, IObject, ISession, SID, UID } from '../../..'; import { FrontendSession } from './frontendSession'; export default class Session extends EventEmitter implements ISession { id: SID; frontendId: FRONTEND_ID; uid: UID; settings: IObject; ivt: NodeJS.Timeout[]; private state; private socket; private sessionService; constructor(sid: SID, frontendId: FRONTEND_ID, socket: IConnectorSocket, service: SessionService); set(values: IObject): void; set(key: string, value: any): void; /** * Remove value from the session. * @param {String} key session key */ remove(key: string): void; /** * Get value from the session. * @param {String} key session key * @return {Object} value associated with session key */ get(key: string): any; /** * 根据session创建frontendSession */ toFrontendSession(): FrontendSession; bind(uid: UID): void; unbind(uid: UID): void; addIvt(ivt: NodeJS.Timeout): void; closed(reason?: string): void; /** * 是否在线 */ get isOnline(): boolean; /** * 获取客户端ip */ getClientIp(): string; send(msg: IMsgRspEncode): void; sendBatch(msg: IMsgRspEncode[]): void; }