refactor(websocket): upgrade socket.io

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-11-18 16:21:56 +08:00
parent d7e757bcf8
commit c5fac44362
26 changed files with 1844 additions and 1680 deletions

View File

@@ -4,43 +4,43 @@
import { Server, ServerOptions } from './socket-io'
interface SocketIOStatic {
/**
* Default Server constructor
*/
(): Server
/**
* Default Server constructor
*/
(): Server
/**
* Creates a new Server
* @param srv The HTTP server that we're going to bind to
* @param opts An optional parameters object
*/
(srv: any, opts?: ServerOptions): Server
/**
* Creates a new Server
* @param srv The HTTP server that we're going to bind to
* @param opts An optional parameters object
*/
(srv: any, opts?: Partial<ServerOptions>): Server
/**
* Creates a new Server
* @param port A port to bind to, as a number, or a string
* @param An optional parameters object
*/
(port: string | number, opts?: ServerOptions): Server
/**
* Creates a new Server
* @param port A port to bind to, as a number, or a string
* @param An optional parameters object
*/
(port: string | number, opts?: Partial<ServerOptions>): Server
/**
* Creates a new Server
* @param A parameters object
*/
(opts: ServerOptions): Server
/**
* Creates a new Server
* @param A parameters object
*/
(opts: Partial<ServerOptions>): Server
/**
* Backwards compatibility
* @see io().listen()
*/
listen?: SocketIOStatic
/**
* Backwards compatibility
* @see io().listen()
*/
listen?: SocketIOStatic
}
type SocketStatic = SocketIOStatic & { Instance?: symbol }
// @ts-ignore
let io: SocketStatic = function (pipeline: any, options: ServerOptions) {
return new Server(pipeline, options)
let io: SocketStatic = function (pipeline: any, options: Partial<ServerOptions>) {
return new Server(pipeline, options)
}
io.Instance = Symbol("@ccms/websocket")
export default io