0.0.3 • Published 6 months ago

one-server-socketio v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

It's a toolkit for nodejs Socket.IO.

Functions

interface IOSocketConfig {
  port?:number; 
  https?:{
    key:string; 
    cert:string;
  },
  auth?: { 
    topic?:string; // 客户端登录验证消息的主题, 用于让服务器识别是否是登录验证的请求,默认AUTH
    secret?:string; // TOKEN的加密密钥
  }
}

/**
 * 建立HTTP(s)连接, 进行Websocket通讯
 * 支持JWT身份验证
 * 客户端Demo: 
  const socket = io('https://localhost:3030', {
    secure: true, // 指定使用安全的 HTTPS 协议
    rejectUnauthorized: false, // 如果不验证证书,设置为 true
    auth: {
      token // 将认证信息放在auth属性中
    }
  })
 */
class IOSocket {
  constructor(filename:string);
  constructor(options:IOSocketConfig);
  handle(callback:(topic:string, msg: string, io:any)=>void): this;
  start(topics:string|string[], callback:(log:string)=>void): this;
}
0.0.3

6 months ago

0.0.2

7 months ago

0.0.1

7 months ago