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