@colyseus/core
Advanced tools
Comparing version 0.15.0-preview.8 to 0.15.0-preview.10
@@ -39,4 +39,4 @@ var __create = Object.create; | ||
const host = await getHostname(); | ||
const port = process.env.SELF_PORT || node.port; | ||
return `${node.processId}/${host}:${port}`; | ||
const port = process.env.SELF_PORT ?? node.port; | ||
return port ? `${node.processId}/${host}:${port}` : `${node.processId}/${host}`; | ||
} | ||
@@ -43,0 +43,0 @@ async function registerNode(presence, node) { |
@@ -124,3 +124,3 @@ var __create = Object.create; | ||
import_Logger.logger.info(`\u274C room "${roomId}" has been disposed. Did you missed .allowReconnection()? | ||
\u{1F449} https://docs.colyseus.io/colyseus/server/room/#allowreconnection-client-seconds`); | ||
\u{1F449} https://docs.colyseus.io/server/room/#allowreconnection-client-seconds`); | ||
throw new import_ServerError.ServerError(import_Protocol.ErrorCode.MATCHMAKE_INVALID_ROOM_ID, `room "${roomId}" has been disposed.`); | ||
@@ -137,3 +137,3 @@ } | ||
import_Logger.logger.info(`\u274C reconnection token invalid or expired. Did you missed .allowReconnection()? | ||
\u{1F449} https://docs.colyseus.io/colyseus/server/room/#allowreconnection-client-seconds`); | ||
\u{1F449} https://docs.colyseus.io/server/room/#allowreconnection-client-seconds`); | ||
throw new import_ServerError.ServerError(import_Protocol.ErrorCode.MATCHMAKE_EXPIRED, `reconnection token invalid or expired.`); | ||
@@ -185,3 +185,3 @@ } | ||
} else { | ||
return !args && typeof room[method] !== "function" ? room[method] : await room[method].apply(room, args); | ||
return !args && typeof room[method] !== "function" ? room[method] : await room[method].apply(room, args && args.map((arg) => JSON.parse(JSON.stringify(arg)))); | ||
} | ||
@@ -188,0 +188,0 @@ } |
@@ -15,3 +15,3 @@ /// <reference types="node" /> | ||
export type SimulationCallback = (deltaTime: number) => void; | ||
export type RoomConstructor<T = any> = new (presence?: Presence) => Room<T>; | ||
export type RoomConstructor<T extends object = any> = new (presence?: Presence) => Room<T>; | ||
export interface IBroadcastOptions extends ISendOptions { | ||
@@ -32,3 +32,3 @@ except?: Client | Client[]; | ||
*/ | ||
export declare abstract class Room<State = any, Metadata = any> { | ||
export declare abstract class Room<State extends object = any, Metadata = any> { | ||
#private; | ||
@@ -35,0 +35,0 @@ /** |
@@ -10,3 +10,3 @@ import { MapSchema, Schema } from '@colyseus/schema'; | ||
declare class State extends Schema { | ||
players: MapSchema<Player>; | ||
players: MapSchema<Player, string>; | ||
} | ||
@@ -13,0 +13,0 @@ /** |
@@ -29,2 +29,7 @@ /// <reference types="node" /> | ||
/** | ||
* Display greeting message on server start. | ||
* Default: true | ||
*/ | ||
greet?: boolean; | ||
/** | ||
* Options below are now part of WebSocketTransport (@colyseus/ws-transport) | ||
@@ -47,2 +52,3 @@ * TODO: remove me on 0.15.0 | ||
protected port: number; | ||
protected greet: boolean; | ||
constructor(options?: ServerOptions); | ||
@@ -68,2 +74,7 @@ attach(options: ServerOptions): void; | ||
define<T extends Type<Room>>(name: string, handler: T, defaultOptions?: Parameters<NonNullable<InstanceType<T>['onCreate']>>[0]): RegisteredHandler; | ||
/** | ||
* Remove a room definition from matchmaking. | ||
* This method does not destroy any room. It only dissallows matchmaking | ||
*/ | ||
removeRoomType(name: string): void; | ||
gracefullyShutdown(exit?: boolean, err?: Error): Promise<void>; | ||
@@ -70,0 +81,0 @@ /** |
@@ -29,2 +29,3 @@ var __create = Object.create; | ||
module.exports = __toCommonJS(Server_exports); | ||
var import_greeting_banner = __toESM(require("@colyseus/greeting-banner")); | ||
var import_Debug = require("./Debug"); | ||
@@ -44,7 +45,9 @@ var matchMaker = __toESM(require("./MatchMaker")); | ||
port; | ||
greet; | ||
constructor(options = {}) { | ||
const { gracefullyShutdown = true } = options; | ||
const { gracefullyShutdown = true, greet = true } = options; | ||
(0, import_DevMode.setDevMode)(options.devMode === true); | ||
this.presence = options.presence || new import_LocalPresence.LocalPresence(); | ||
this.driver = options.driver || new import_driver.LocalDriver(); | ||
this.greet = greet; | ||
this.attach(options); | ||
@@ -87,2 +90,5 @@ matchMaker.setup( | ||
await matchMaker.onReady; | ||
if (this.greet) { | ||
console.log(import_greeting_banner.default); | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -111,2 +117,5 @@ this.transport.server?.on("error", (err) => reject(err)); | ||
} | ||
removeRoomType(name) { | ||
matchMaker.removeRoomType(name); | ||
} | ||
async gracefullyShutdown(exit = true, err) { | ||
@@ -113,0 +122,0 @@ if (matchMaker.isGracefullyShuttingDown) { |
{ | ||
"name": "@colyseus/core", | ||
"version": "0.15.0-preview.8", | ||
"version": "0.15.0-preview.10", | ||
"description": "Multiplayer Framework for Node.js.", | ||
@@ -37,2 +37,3 @@ "input": "./src/index.ts", | ||
"dependencies": { | ||
"@colyseus/greeting-banner": "^2.0.0", | ||
"@colyseus/schema": "^2.0.4", | ||
@@ -43,3 +44,3 @@ "@gamestdio/timer": "^1.3.0", | ||
"internal-ip": "^4.3.0", | ||
"msgpackr": "^1.6.1", | ||
"msgpackr": "^1.9.1", | ||
"nanoid": "^2.0.0" | ||
@@ -50,3 +51,3 @@ }, | ||
}, | ||
"gitHead": "c45b410e99eadffff4b74e701339992e2faa15f8" | ||
"gitHead": "ea2d4185ffd68c231b48c77c3804c59622072c1c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
613761
7084
8
+ Added@colyseus/greeting-banner@2.0.3(transitive)
Updatedmsgpackr@^1.9.1