feat: support websocket connections from game client #2735
@ -1,6 +1,6 @@
 | 
			
		||||
import type http from "http";
 | 
			
		||||
import type https from "https";
 | 
			
		||||
import type { default as ws } from "ws";
 | 
			
		||||
import type { WebSocket } from "ws";
 | 
			
		||||
import { WebSocketServer } from "ws";
 | 
			
		||||
import { Account } from "../models/loginModel.ts";
 | 
			
		||||
import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "./loginService.ts";
 | 
			
		||||
@ -44,7 +44,7 @@ export const stopWsServers = (promises: Promise<void>[]): void => {
 | 
			
		||||
 | 
			
		||||
let lastWsid: number = 0;
 | 
			
		||||
 | 
			
		||||
interface IWsCustomData extends ws {
 | 
			
		||||
interface IWsCustomData extends WebSocket {
 | 
			
		||||
    id: number;
 | 
			
		||||
    accountId?: string;
 | 
			
		||||
    isGame?: boolean;
 | 
			
		||||
@ -90,7 +90,7 @@ interface IWsMsgToClient {
 | 
			
		||||
    sync_inventory?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
 | 
			
		||||
const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
 | 
			
		||||
    if (req.url == "/custom/selftest") {
 | 
			
		||||
        ws.send("SpaceNinjaServer");
 | 
			
		||||
        ws.close();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user