* Unified profiles, rather than instantiating profiles every time we want to access one
* Socket and live instance changes * Possible problem with Deno's handling of sockets, compatibility issue with Node?
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import WebSocket from "ws";
|
||||
import Profile from "../data/profiles.ts";
|
||||
import { IncomingMessage } from "node:http";
|
||||
import { Profile } from "../data/profiles.ts";
|
||||
import Logging from "@proxnet/undead-logging";
|
||||
|
||||
export class SignalRSocketHandler {
|
||||
@@ -11,15 +10,13 @@ export class SignalRSocketHandler {
|
||||
#profile: Profile;
|
||||
|
||||
constructor(socket: WebSocket, player: Profile) {
|
||||
|
||||
|
||||
this.#socket = socket;
|
||||
this.#initLogSource();
|
||||
|
||||
this.#profile = player;
|
||||
|
||||
throw new Error("This will fail due to undefined access attempt. Debug this. Also, please unify profiles.");
|
||||
player.setSocketHandler(this);
|
||||
this.log.source += player.getId().toString();
|
||||
|
||||
// log: we connected!!
|
||||
|
||||
Deno.addSignalListener('SIGINT', this.destroy);
|
||||
|
||||
@@ -30,4 +27,17 @@ export class SignalRSocketHandler {
|
||||
Deno.removeSignalListener('SIGINT', this.destroy);
|
||||
}
|
||||
|
||||
async #initLogSource() {
|
||||
this.log.source += this.#profile.getId().toString();
|
||||
|
||||
this.log.i(`Player '${(await this.#profile.export())?.username}' (${this.#profile.getId()}) created hub socket`);
|
||||
|
||||
this.#socket.on('open', () => {
|
||||
this.log.d(`hello world`)
|
||||
});
|
||||
this.#socket.on('message', data => {
|
||||
this.log.d(data.toString());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user