@antha/multiplayer-p2p-authoritative-host 0.0.1 → 0.0.3

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.
@@ -1,4 +1,4 @@
1
- import { type ApiAndRoomConnectionState, type MultiplayerClientRooms } from '@antha/multiplayer-core';
1
+ import { type ApiAndRoomConnectionState } from '@antha/multiplayer-core';
2
2
  import { type JsonCompatibleValue, type PartialWithUndefined, type SelectFrom } from '@augment-vir/common';
3
3
  import { P2pAuthoritativeHostMultiplayerController, type P2pAuthoritativeHostMultiplayerControllerParams } from './p2p-authoritative-host-multiplayer-controller.js';
4
4
  /**
@@ -13,8 +13,6 @@ export type AnthaMultiplayerP2pAuthoritativeHostState<Input extends JsonCompatib
13
13
  multiplayerController: P2pAuthoritativeHostMultiplayerController<Input, State>;
14
14
  /** Current backend API and room connection state. */
15
15
  connectionState: ApiAndRoomConnectionState;
16
- /** Rooms currently available for joining. */
17
- availableRooms: MultiplayerClientRooms;
18
16
  /** Latest state emitted by the multiplayer controller. */
19
17
  currentState: State;
20
18
  };
@@ -1,5 +1,5 @@
1
1
  import { defineAnthaMod } from '@antha/engine';
2
- import { ControllerConnectionEvent, ControllerRoomListEvent, emptyApiAndRoomConnectionState, } from '@antha/multiplayer-core';
2
+ import { ControllerConnectionEvent, emptyApiAndRoomConnectionState, } from '@antha/multiplayer-core';
3
3
  import { ControllerStateEvent, P2pAuthoritativeHostMultiplayerController, } from './p2p-authoritative-host-multiplayer-controller.js';
4
4
  /**
5
5
  * Create the engine mod that owns p2p-authoritative-host multiplayer state.
@@ -18,12 +18,6 @@ export function createAnthaMultiplayerP2pAuthoritativeHostMod(options) {
18
18
  }
19
19
  state.multiplayerP2pAuthoritativeHost.connectionState = newConnectionState;
20
20
  });
21
- state.multiplayerP2pAuthoritativeHost.multiplayerController.listen(ControllerRoomListEvent, ({ detail: rooms }) => {
22
- if (!state.multiplayerP2pAuthoritativeHost) {
23
- return;
24
- }
25
- state.multiplayerP2pAuthoritativeHost.availableRooms = rooms;
26
- });
27
21
  state.multiplayerP2pAuthoritativeHost.multiplayerController.listen((ControllerStateEvent), ({ detail }) => {
28
22
  if (!state.multiplayerP2pAuthoritativeHost) {
29
23
  return;
@@ -55,7 +49,6 @@ function createP2pAuthoritativeHostState(options) {
55
49
  return {
56
50
  multiplayerController,
57
51
  connectionState: emptyApiAndRoomConnectionState,
58
- availableRooms: {},
59
52
  currentState: multiplayerController.getState(),
60
53
  };
61
54
  }
@@ -1,4 +1,4 @@
1
- import { type ApiAndRoomConnectionState, type ClientId, ControllerClientEvent, ControllerConnectionEvent, ControllerRoomListEvent, type MultiplayerInitParams, type MultiplayerRoomConnection, MultiplayerRoomController, type RoomInput, RoomRejectionError } from '@antha/multiplayer-core';
1
+ import { type ApiAndRoomConnectionState, type ClientId, ControllerClientEvent, ControllerConnectionEvent, ControllerRoomListEvent, type ControllerRoomListListener, type MultiplayerInitParams, type MultiplayerRoomConnection, MultiplayerRoomController, type RoomInput, RoomRejectionError } from '@antha/multiplayer-core';
2
2
  import { type JsonCompatibleValue, type MaybePromise, type PartialWithUndefined } from '@augment-vir/common';
3
3
  import { ListenTarget, type TypedCustomEventInit } from 'typed-event-target';
4
4
  /**
@@ -148,12 +148,13 @@ export declare class P2pAuthoritativeHostMultiplayerController<Input extends Jso
148
148
  /** The current client id. */
149
149
  get clientId(): ClientId;
150
150
  /**
151
- * Set to `false` to disable room updates, even when still not connected to a room in
152
- * multiplayer mode.
151
+ * Listen for room list updates, including while connected to a room.
152
+ *
153
+ * If a callback is provided, it is called each time the room list is updated.
153
154
  */
154
- get enableRoomUpdates(): boolean;
155
- /** Update whether room list polling is enabled while not connected to a room. */
156
- set enableRoomUpdates(value: boolean);
155
+ startRoomUpdates(callback?: ControllerRoomListListener | undefined): import("typed-event-target").RemoveListenerCallback;
156
+ /** Turn off room list updates and remove callbacks added via `startRoomUpdates`. */
157
+ stopRoomUpdates(): void;
157
158
  /** Currently joined room id. If a room has not been joined yet, this will be empty. */
158
159
  get roomId(): import("@antha/multiplayer-core").RoomId | undefined;
159
160
  /** The current connection state of the controller's connection to a backend API. */
@@ -67,15 +67,16 @@ export class P2pAuthoritativeHostMultiplayerController extends ListenTarget {
67
67
  return this.roomConnection?.clientId || this.localClientId;
68
68
  }
69
69
  /**
70
- * Set to `false` to disable room updates, even when still not connected to a room in
71
- * multiplayer mode.
70
+ * Listen for room list updates, including while connected to a room.
71
+ *
72
+ * If a callback is provided, it is called each time the room list is updated.
72
73
  */
73
- get enableRoomUpdates() {
74
- return this.roomController.enableRoomUpdates;
74
+ startRoomUpdates(callback) {
75
+ return this.roomController.startRoomUpdates(callback);
75
76
  }
76
- /** Update whether room list polling is enabled while not connected to a room. */
77
- set enableRoomUpdates(value) {
78
- this.roomController.enableRoomUpdates = value;
77
+ /** Turn off room list updates and remove callbacks added via `startRoomUpdates`. */
78
+ stopRoomUpdates() {
79
+ this.roomController.stopRoomUpdates();
79
80
  }
80
81
  /** Currently joined room id. If a room has not been joined yet, this will be empty. */
81
82
  get roomId() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/multiplayer-p2p-authoritative-host",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "P2P authoritative-host multiplayer strategy for the Antha engine.",
5
5
  "keywords": [
6
6
  "vir",
@@ -48,7 +48,7 @@
48
48
  "istanbul-smart-text-reporter": "^1.1.5"
49
49
  },
50
50
  "peerDependencies": {
51
- "@antha/multiplayer-core": "^0.0.1"
51
+ "@antha/multiplayer-core": "^0.0.3"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=22"