make wsupgrade async

This commit is contained in:
HF 2023-06-15 23:24:56 +02:00
parent 5c353dd8c2
commit bfa3e19c2c

View File

@ -43,11 +43,11 @@ const server = http.createServer(app);
// -----------------------------------------------------------------------------
const usersocket = new SocketServer();
const apisocket = new APISocketServer();
function wsupgrade(request, socket, head) {
async function wsupgrade(request, socket, head) {
const { pathname } = url.parse(request.url);
try {
if (pathname === '/ws') {
usersocket.handleUpgrade(request, socket, head);
await usersocket.handleUpgrade(request, socket, head);
} else if (pathname === '/mcws') {
apisocket.handleUpgrade(request, socket, head);
} else {