@colyseus/monitor 0.15.0-preview.3 → 0.15.0

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/.editorconfig ADDED
@@ -0,0 +1,6 @@
1
+ [*]
2
+ end_of_line = lf
3
+ charset = utf-8
4
+ trim_trailing_whitespace = true
5
+ indent_style = space
6
+ indent_size = 2
package/build/api.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import { MonitorOptions } from ".";
2
- export declare function getAPI(opts: Partial<MonitorOptions>): import("express-serve-static-core").Router;
2
+ export declare function getAPI(opts: Partial<MonitorOptions>): any;
package/build/api.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getAPI = void 0;
16
- const colyseus_1 = require("colyseus");
16
+ const core_1 = require("@colyseus/core");
17
17
  const express_1 = __importDefault(require("express"));
18
18
  const node_os_utils_1 = __importDefault(require("node-os-utils"));
19
19
  const UNAVAILABLE_ROOM_ERROR = "@colyseus/monitor: room $roomId is not available anymore.";
@@ -21,7 +21,7 @@ function getAPI(opts) {
21
21
  const api = express_1.default.Router();
22
22
  api.get("/", (req, res) => __awaiter(this, void 0, void 0, function* () {
23
23
  try {
24
- const rooms = yield colyseus_1.matchMaker.query({});
24
+ const rooms = yield core_1.matchMaker.query({});
25
25
  const columns = opts.columns || ['roomId', 'name', 'clients', 'maxClients', 'locked', 'elapsedTime'];
26
26
  // extend columns to expose "publicAddress", if present
27
27
  if (!opts.columns && rooms[0] && rooms[0].publicAddress !== undefined) {
@@ -55,7 +55,7 @@ function getAPI(opts) {
55
55
  api.get("/room", (req, res) => __awaiter(this, void 0, void 0, function* () {
56
56
  const roomId = req.query.roomId;
57
57
  try {
58
- const inspectData = yield colyseus_1.matchMaker.remoteRoomCall(roomId, "getInspectData");
58
+ const inspectData = yield core_1.matchMaker.remoteRoomCall(roomId, "getInspectData");
59
59
  res.json(inspectData);
60
60
  }
61
61
  catch (e) {
@@ -70,7 +70,7 @@ function getAPI(opts) {
70
70
  const method = req.query.method;
71
71
  const args = JSON.parse(req.query.args);
72
72
  try {
73
- const data = yield colyseus_1.matchMaker.remoteRoomCall(roomId, method, args);
73
+ const data = yield core_1.matchMaker.remoteRoomCall(roomId, method, args);
74
74
  res.json(data);
75
75
  }
76
76
  catch (e) {
package/build/ext/Room.js CHANGED
@@ -12,14 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  //
13
13
  // Monkey-patch Colyseus' default behaviour
14
14
  //
15
- const colyseus_1 = require("colyseus");
15
+ const core_1 = require("@colyseus/core");
16
16
  function getStateSize(room) {
17
17
  // TODO: `Serializer<T>` should provide a method for this (e.g. `serializer.hasState()`)
18
18
  const hasState = (room._serializer.state || room._serializer.previousState);
19
19
  const fullState = hasState && room._serializer.getFullState();
20
20
  return fullState && (fullState.byteLength || fullState.length) || 0;
21
21
  }
22
- colyseus_1.Room.prototype.getAvailableData = function () {
22
+ core_1.Room.prototype.getAvailableData = function () {
23
23
  return {
24
24
  clients: this.clients.length,
25
25
  maxClients: this.maxClients,
@@ -27,7 +27,7 @@ colyseus_1.Room.prototype.getAvailableData = function () {
27
27
  roomId: this.roomId,
28
28
  };
29
29
  };
30
- colyseus_1.Room.prototype.getRoomListData = function () {
30
+ core_1.Room.prototype.getRoomListData = function () {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
32
  const stateSize = getStateSize(this);
33
33
  const elapsedTime = this.clock.elapsedTime;
@@ -36,7 +36,7 @@ colyseus_1.Room.prototype.getRoomListData = function () {
36
36
  return Object.assign(Object.assign({}, data), { locked, elapsedTime, stateSize });
37
37
  });
38
38
  };
39
- colyseus_1.Room.prototype.getInspectData = function () {
39
+ core_1.Room.prototype.getInspectData = function () {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  const state = this.state;
42
42
  const stateSize = getStateSize(this);
@@ -47,17 +47,17 @@ colyseus_1.Room.prototype.getInspectData = function () {
47
47
  });
48
48
  };
49
49
  // Actions
50
- colyseus_1.Room.prototype._forceClientDisconnect = function (sessionId) {
50
+ core_1.Room.prototype._forceClientDisconnect = function (sessionId) {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
52
  for (let i = 0; i < this.clients.length; i++) {
53
53
  if (this.clients[i].sessionId === sessionId) {
54
- this.clients[i].terminate();
54
+ this.clients[i].leave();
55
55
  break;
56
56
  }
57
57
  }
58
58
  });
59
59
  };
60
- colyseus_1.Room.prototype._sendMessageToClient = function (sessionId, type, data) {
60
+ core_1.Room.prototype._sendMessageToClient = function (sessionId, type, data) {
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
62
  for (let i = 0; i < this.clients.length; i++) {
63
63
  if (this.clients[i].sessionId === sessionId) {
package/build/index.js CHANGED
@@ -15,7 +15,7 @@ const frontendDirectory = path_1.default.resolve(__dirname, "..", "build", "stat
15
15
  function monitor(opts = {}) {
16
16
  const router = express_1.default.Router();
17
17
  router.use(express_1.default.static(frontendDirectory));
18
- router.use('/api', api_1.getAPI(opts));
18
+ router.use('/api', (0, api_1.getAPI)(opts));
19
19
  return router;
20
20
  }
21
21
  exports.monitor = monitor;
@@ -1,2 +1,2 @@
1
1
  import { MonitorOptions } from ".";
2
- export declare function getAPI(opts: Partial<MonitorOptions>): import("express-serve-static-core").Router;
2
+ export declare function getAPI(opts: Partial<MonitorOptions>): any;