@wxn0brp/gloves-link-server 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -10,7 +10,6 @@ import { Server_Opts } from "./types.js";
10
10
  */
11
11
  export declare class GlovesLinkServer {
12
12
  wss: WebSocketServer;
13
- logs: boolean;
14
13
  opts: Server_Opts;
15
14
  initStatusTemp: Record<string, {
16
15
  status: number;
package/dist/index.js CHANGED
@@ -8,7 +8,6 @@ import { GLSocket } from "./socket.js";
8
8
  */
9
9
  export class GlovesLinkServer {
10
10
  wss;
11
- logs = false;
12
11
  opts;
13
12
  initStatusTemp = {};
14
13
  rooms = new Map();
@@ -55,7 +54,7 @@ export class GlovesLinkServer {
55
54
  }
56
55
  this.wss.handleUpgrade(request, socket, head, (ws) => {
57
56
  const glSocket = new GLSocket(ws, this);
58
- glSocket.logs = this.logs;
57
+ glSocket.logs = this.opts.logs;
59
58
  glSocket.authData = authData;
60
59
  glSocket.authResult = authResult;
61
60
  if (typeof authResult.user === "object" && authResult.user !== null)
@@ -72,8 +71,8 @@ export class GlovesLinkServer {
72
71
  catch (err) {
73
72
  if (process.env.NODE_ENV === "development")
74
73
  console.error("[GlovesLinkServer]", err);
75
- if (this.logs)
76
- console.warn("[auth] Error during authentication:", err);
74
+ if (this.opts.logs)
75
+ console.warn("[ws auth] Error during authentication:", err);
77
76
  this.saveSocketStatus(socketSelfId, "/", 500);
78
77
  socket.write("HTTP/1.1 500 Internal Server Error\r\n\r\n");
79
78
  socket.destroy();
package/dist/socket.d.ts CHANGED
@@ -93,4 +93,5 @@ export declare class GLSocket<T = {
93
93
  * @returns A map of all rooms on the server
94
94
  */
95
95
  serverRooms(): Rooms;
96
+ disconnect(): void;
96
97
  }
package/dist/socket.js CHANGED
@@ -46,6 +46,8 @@ export class GLSocket {
46
46
  }
47
47
  if ("ack" in msg) {
48
48
  const ackId = msg.ack;
49
+ if (this.logs)
50
+ console.log("[ws] Received ack:", ackId);
49
51
  const ackCallback = this.ackCallbacks.get(ackId);
50
52
  if (ackCallback) {
51
53
  this.ackCallbacks.delete(ackId);
@@ -56,6 +58,8 @@ export class GLSocket {
56
58
  const { evt, data, ackI } = msg;
57
59
  if (!evt || (data && !Array.isArray(data)))
58
60
  return;
61
+ if (this.logs)
62
+ console.log("[ws] Received event:", evt, data);
59
63
  if (Array.isArray(ackI)) {
60
64
  for (let i = 0; i < ackI.length; i++) {
61
65
  const ackIndex = ackI[i];
@@ -168,4 +172,7 @@ export class GLSocket {
168
172
  serverRooms() {
169
173
  return this.server.rooms;
170
174
  }
175
+ disconnect() {
176
+ this.ws.close();
177
+ }
171
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/gloves-link-server",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",