1.1.6 • Published 3 years ago

wss-env v1.1.6

Weekly downloads
10
License
MIT
Repository
github
Last release
3 years ago

wss-env

install

npm i wss-env

options

usage

import { join } from 'path';
import { createServer } from 'http';
import { Server } from 'wssio';
import { namespaceAutoload } from 'wss-autoload';
import { namespacePlugin } from 'wss-plugin';
import { namespaceEnv } from 'wss-env';
const server = createServer();
const wssio = new Server({
  server,
});
const nsp = wssio.of('/test');
// 注册关闭钩子函数、以达到关闭服务
nsp.register(namespacePlugin((namespace, _opts, done) => {
  namespace.addHook('onClose', () => {
    wssio.close();
    server.close();
  });
  done();
}, {
  name: 'onClose',
}));
nsp.register(namespaceEnv, {
  schema: {
    type: 'object',
    required: ['PORT'],
    properties: {
      PORT: {
        type: 'integer',
        default: 888
      }
    }
  }
}).ready((err)=>{
  nsp.$log.info('wss ready.....');
  nsp.$log.info(b.config.PORT==888);
  server.listen(3000, '0.0.0.0');
})
1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago