0.0.8 • Published 12 months ago

@gulibs/tegg-wss v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

TEGG wss Plugin

tegg的Websocket插件

NPM

安装

npm install --save @gulibs/tegg-wss

or

yarn add @gulibs/tegg-wss

使用和配置

  • config.default.ts
const config = {
    wss: {
      options: {
        noServer: true
        // host: '127.0.0.1',
        // port: 9100
      },
      heartbeat: { // 开启心跳功能
        ms: 30000, //执行间隔时间
        logging: true //打印日志
      },
      namespace: {
        "/chat": {
          middleware: ['auth', 'chat']
        }
      }
    },
} as PowerPartial<EggAppConfig>;
  • plugin.ts
teggWebsocket: {
    enable: true,
    package: "@gulibs/tegg-wss"
}
  • 中间件配置

创建/app/wss/middleware,然后在/app/wss/middleware目录创建中间件.ts文件.

所有配置

interface TeggWssHeartbeat {
    ms?: number;
    logging?: boolean;
}

interface TeggWssConfig {
    options: ServerOptions;
    heartbeat?: TeggWssHeartbeat;
    generateClient?: (data: TeggWssRawFields) => TeggWssClient; //自定义client
    namespace: Record<string, TeggWssMiddleware>;
}

interface Application {
    wss: EggWebSocketServer;
    clientManager: ClientManager;
    currentClient: TeggWssClient;
}

interface EggAppConfig {
    wss: TeggWssConfig;
}
0.0.8

12 months ago

0.0.7

12 months ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.6

2 years ago

0.0.1

3 years ago