@eleven-am/pondsocket 0.1.213 → 0.1.215

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/types.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DistributedMessageType = void 0;
4
+ var DistributedMessageType;
5
+ (function (DistributedMessageType) {
6
+ DistributedMessageType["STATE_REQUEST"] = "STATE_REQUEST";
7
+ DistributedMessageType["STATE_RESPONSE"] = "STATE_RESPONSE";
8
+ DistributedMessageType["USER_JOINED"] = "USER_JOINED";
9
+ DistributedMessageType["USER_LEFT"] = "USER_LEFT";
10
+ DistributedMessageType["USER_MESSAGE"] = "USER_MESSAGE";
11
+ DistributedMessageType["PRESENCE_UPDATE"] = "PRESENCE_UPDATE";
12
+ DistributedMessageType["PRESENCE_REMOVED"] = "PRESENCE_REMOVED";
13
+ DistributedMessageType["ASSIGNS_UPDATE"] = "ASSIGNS_UPDATE";
14
+ DistributedMessageType["EVICT_USER"] = "EVICT_USER";
15
+ DistributedMessageType["NODE_HEARTBEAT"] = "NODE_HEARTBEAT";
16
+ })(DistributedMessageType || (exports.DistributedMessageType = DistributedMessageType = {}));
@@ -0,0 +1,54 @@
1
+ import { PondMessage, PondAssigns, PondPresence } from '@eleven-am/pondsocket-common';
2
+ import { ChannelEngine } from '../engines/channelEngine';
3
+ export declare class Channel {
4
+ #private;
5
+ constructor(engine: ChannelEngine);
6
+ /**
7
+ * Gets a user's data
8
+ */
9
+ getUserData(userId: string): import("@eleven-am/pondsocket-common").UserData<import("@eleven-am/pondsocket-common").PondObject, import("@eleven-am/pondsocket-common").PondObject>;
10
+ /**
11
+ * Gets all presence data
12
+ */
13
+ getPresences(): import("@eleven-am/pondsocket-common").UserPresences;
14
+ /**
15
+ * Gets all assigns data
16
+ */
17
+ getAssigns(): import("@eleven-am/pondsocket-common").UserAssigns;
18
+ /**
19
+ * Broadcasts a message to all users
20
+ */
21
+ broadcast(event: string, payload: PondMessage): this;
22
+ /**
23
+ * Broadcasts a message from a specific user to all others
24
+ */
25
+ broadcastFrom(userId: string, event: string, payload: PondMessage): this;
26
+ /**
27
+ * Broadcasts a message to specific users
28
+ */
29
+ broadcastTo(userIds: string | string[], event: string, payload: PondMessage): this;
30
+ /**
31
+ * Kicks a user from the channel
32
+ */
33
+ evictUser(userId: string, reason?: string): this;
34
+ /**
35
+ * Tracks a user's presence
36
+ */
37
+ trackPresence(userId: string, presence: PondPresence): this;
38
+ /**
39
+ * Updates a user's presence
40
+ */
41
+ updatePresence(userId: string, presence: PondPresence): this;
42
+ /**
43
+ * Removes a user's presence
44
+ */
45
+ removePresence(userId: string): this;
46
+ /**
47
+ * Adds or updates a user's presence
48
+ */
49
+ upsertPresence(userId: string, presence: PondPresence): this;
50
+ /**
51
+ * Updates a user's assigns
52
+ */
53
+ updateAssigns(userId: string, assigns: PondAssigns): this;
54
+ }
@@ -0,0 +1,10 @@
1
+ import { PondPath } from '@eleven-am/pondsocket-common';
2
+ import { AuthorizationHandler } from '../abstracts/types';
3
+ import { EndpointEngine } from '../engines/endpointEngine';
4
+ export declare class Endpoint {
5
+ #private;
6
+ constructor(engine: EndpointEngine);
7
+ createChannel<Path extends string>(path: PondPath<Path>, handler: AuthorizationHandler<Path>): import("./pondChannel").PondChannel;
8
+ closeConnection(clientIds: string | string[]): void;
9
+ getClients(): import("ws").WebSocket[];
10
+ }
@@ -0,0 +1,15 @@
1
+ import { PondMessage, PondPath } from '@eleven-am/pondsocket-common';
2
+ import { Channel } from './channel';
3
+ import { EventHandler, LeaveCallback, OutgoingEventHandler } from '../abstracts/types';
4
+ import { LobbyEngine } from '../engines/lobbyEngine';
5
+ export declare class PondChannel {
6
+ #private;
7
+ constructor(lobby: LobbyEngine);
8
+ onEvent<Event extends string>(event: PondPath<Event>, handler: EventHandler<Event>): PondChannel;
9
+ onLeave(callback: LeaveCallback): PondChannel;
10
+ handleOutgoingEvent<Event extends string>(event: PondPath<Event>, handler: OutgoingEventHandler<Event>): this;
11
+ getChannel(channelName: string): Channel | null;
12
+ broadcast(channelName: string, event: string, payload: PondMessage): PondChannel;
13
+ broadcastFrom(channelName: string, userId: string, event: string, payload: PondMessage): PondChannel;
14
+ broadcastTo(channelName: string, userIds: string | string[], event: string, payload: PondMessage): PondChannel;
15
+ }