logging
This commit is contained in:
		
							parent
							
								
									07b9bc9415
								
							
						
					
					
						commit
						b03096d180
					
				@ -6,7 +6,7 @@ import { Account } from "../models/loginModel.ts";
 | 
				
			|||||||
import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "./loginService.ts";
 | 
					import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "./loginService.ts";
 | 
				
			||||||
import type { IDatabaseAccountJson } from "../types/loginTypes.ts";
 | 
					import type { IDatabaseAccountJson } from "../types/loginTypes.ts";
 | 
				
			||||||
import type { HydratedDocument } from "mongoose";
 | 
					import type { HydratedDocument } from "mongoose";
 | 
				
			||||||
import { logError } from "../utils/logger.ts";
 | 
					import { logError, logger } from "../utils/logger.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let wsServer: WebSocketServer | undefined;
 | 
					let wsServer: WebSocketServer | undefined;
 | 
				
			||||||
let wssServer: WebSocketServer | undefined;
 | 
					let wssServer: WebSocketServer | undefined;
 | 
				
			||||||
@ -158,6 +158,7 @@ const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
 | 
				
			|||||||
                    });
 | 
					                    });
 | 
				
			||||||
                    if (account) {
 | 
					                    if (account) {
 | 
				
			||||||
                        (ws as IWsCustomData).accountId = account.id;
 | 
					                        (ws as IWsCustomData).accountId = account.id;
 | 
				
			||||||
 | 
					                        logger.debug(`got bootstrapper connection for ${account.id}`);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -180,6 +181,7 @@ const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
    ws.on("close", () => {
 | 
					    ws.on("close", () => {
 | 
				
			||||||
        if ((ws as IWsCustomData).isGame && (ws as IWsCustomData).accountId) {
 | 
					        if ((ws as IWsCustomData).isGame && (ws as IWsCustomData).accountId) {
 | 
				
			||||||
 | 
					            logger.debug(`lost bootstrapper connection for ${(ws as IWsCustomData).accountId}`);
 | 
				
			||||||
            void Account.updateOne(
 | 
					            void Account.updateOne(
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _id: (ws as IWsCustomData).accountId
 | 
					                    _id: (ws as IWsCustomData).accountId
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user