feat: upgrade socket.io to v4

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2022-11-21 23:18:39 +08:00
parent e563e1b507
commit df0d246136
45 changed files with 6585 additions and 1734 deletions

View File

@@ -1,10 +1,45 @@
// import { createServer } from "http"
import { Server, AttachOptions, ServerOptions } from "./server"
import transports from "./transports/index"
import * as parser from "../engine.io-parser"
// export { Server, transports, listen, attach, parser }
export { Server, transports, attach, parser }
export { AttachOptions, ServerOptions } from "./server"
// export { uServer } from "./userver";
export { Socket } from "./socket"
export { Transport } from "./transport"
export const protocol = parser.protocol
/**
* Module dependencies.
* Creates an http.Server exclusively used for WS upgrades.
*
* @param {Number} port
* @param {Function} callback
* @param {Object} options
* @return {Server} websocket.io server
* @api public
*/
// const http = require("http")
// const Server = require("./server")
import { Server } from './server'
// function listen(port, options: AttachOptions & ServerOptions, fn) {
// if ("function" === typeof options) {
// fn = options;
// options = {};
// }
// const server = createServer(function(req, res) {
// res.writeHead(501);
// res.end("Not Implemented");
// });
// // create engine server
// const engine = attach(server, options);
// engine.httpServer = server;
// server.listen(port, fn);
// return engine;
// }
/**
* Captures upgrade requests for a http.Server.
@@ -15,12 +50,8 @@ import { Server } from './server'
* @api public
*/
function attach(srv, options) {
function attach(server, options: AttachOptions & ServerOptions) {
const engine = new Server(options)
engine.attach(srv, options)
engine.attach(server, options)
return engine
}
export = {
attach
}