@pieai/swimmer-game-server-kit 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # SwimmerGameServerKit
2
2
 
3
+ TCP listeners honor `config.host` (local default `127.0.0.1`) through the existing
4
+ WebSocket transport. The upstream Colyseus tools still own process-port offsets,
5
+ Cloud Unix sockets, matchmaking and shutdown. Keep the same config when creating
6
+ and starting an app. Binding is tested using real IPv4/IPv6 sockets, an HTTP health
7
+ request, WebSocket room joins and a Unix socket, not just configuration objects.
8
+
3
9
  Shared Colyseus game-server kit for PieAI Swimmer-based games.
4
10
 
5
11
  This repository is the central template for PieAI multiplayer game servers.
package/dist/colyseus.js CHANGED
@@ -2,6 +2,21 @@ import defineServer, { listen } from '@colyseus/tools';
2
2
  import { defineRoom } from '@colyseus/core';
3
3
  import { WebSocketTransport } from '@colyseus/ws-transport';
4
4
  import { configureGameServerHttpRoutes } from './http.js';
5
+ /** @colyseus/tools owns Cloud sockets, process ports and server lifecycle, but
6
+ * its TCP listen helper omits hostname. Supply it at the existing transport
7
+ * extension point, before any socket binds; never bind publicly then rebind. */
8
+ class HostBoundWebSocketTransport extends WebSocketTransport {
9
+ bindHost;
10
+ constructor(options, bindHost) {
11
+ super(options);
12
+ this.bindHost = bindHost;
13
+ }
14
+ listen(port, hostname, backlog, listeningListener) {
15
+ // The Cloud helper passes a Unix socket path through this numeric API.
16
+ // A path is not a TCP port; preserve the native socket overload unchanged.
17
+ return super.listen(port, typeof port === 'number' ? this.bindHost : hostname, backlog, listeningListener);
18
+ }
19
+ }
5
20
  export function createSwimmerGameServerApp(options) {
6
21
  const roomDefinitions = Object.fromEntries(options.rooms.map((registration) => {
7
22
  const handler = defineRoom(registration.room);
@@ -14,13 +29,8 @@ export function createSwimmerGameServerApp(options) {
14
29
  const transport = options.transport;
15
30
  return defineServer({
16
31
  displayLogs: options.displayLogs ?? true,
17
- // Mirror @colyseus/tools' default transport, layering the caller's ping
18
- // settings on top of the runtime-provided options (http server handle).
19
- ...(transport === undefined
20
- ? {}
21
- : {
22
- initializeTransport: (transportOptions) => new WebSocketTransport({ ...transportOptions, ...transport }),
23
- }),
32
+ // Keep the upstream HTTP handle, ping settings, matchmaking and shutdown.
33
+ initializeTransport: (transportOptions) => new HostBoundWebSocketTransport({ ...transportOptions, ...transport }, options.config.host),
24
34
  rooms: roomDefinitions,
25
35
  initializeExpress(app) {
26
36
  configureGameServerHttpRoutes(app, options.config, options.extraHealth === undefined
@@ -1 +1 @@
1
- {"version":3,"file":"colyseus.js","sourceRoot":"","sources":["../src/colyseus.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAa,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAmC1D,MAAM,UAAU,0BAA0B,CAAC,OAA0C;IACnF,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CACxC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;QACjC,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9D,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAA2C,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC,CACH,CAAC;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE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AE,GAAG,gBAAgB,EAAE,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;QAC7F,KAAK,EAAE,eAAe;QACtB,iBAAiB,CAAC,GAAG;YACnB,6BAA6B,CAC3B,GAAG,EACH,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,WAAW,KAAK,SAAS;gBAC/B,CAAC,CAAC,EAAE,SAAS,EAAE;gBACf,CAAC,CAAC;oBACE,WAAW,EAAE,OAAO,CAAC,WAAW;oBAChC,SAAS;iBACV,CACN,CAAC;YACF,OAAO,CAAC,iBAAiB,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,GAAkD,EAClD,MAAwB;IAExB,OAAO,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pieai/swimmer-game-server-kit",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Shared Colyseus game server kit for PieAI Swimmer-based games.",
5
5
  "keywords": [
6
6
  "colyseus",
@@ -82,8 +82,8 @@
82
82
  "zod": "^4.1.13"
83
83
  },
84
84
  "devDependencies": {
85
- "@pieai/doc-gov": "0.8.0",
86
- "@pieai/pro-gov": "0.8.0",
85
+ "@pieai/doc-gov": "0.9.11",
86
+ "@pieai/pro-gov": "0.9.11",
87
87
  "@types/cors": "^2.8.19",
88
88
  "@types/express": "^5.0.6",
89
89
  "@types/node": "24.13.2",
@@ -102,7 +102,7 @@
102
102
  "lint": "oxlint src tests templates/colyseus-game-server/src -c ./.oxlintrc.json",
103
103
  "format": "oxfmt package.json tsconfig.json tsconfig.build.json templates/colyseus-game-server/package.json templates/colyseus-game-server/tsconfig.json src tests templates/colyseus-game-server/src --write --ignore-path ./.oxfmtignore",
104
104
  "format:check": "oxfmt package.json tsconfig.json tsconfig.build.json templates/colyseus-game-server/package.json templates/colyseus-game-server/tsconfig.json src tests templates/colyseus-game-server/src --check --ignore-path ./.oxfmtignore",
105
- "test": "vitest run --pool threads",
105
+ "test": "vitest run tests --pool threads",
106
106
  "verify": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm test && pnpm build",
107
107
  "doc-gov": "doc-gov",
108
108
  "pro-gov": "pro-gov",