@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/abstracts/distributor.d.ts +13 -0
- package/abstracts/distributor.js +121 -54
- package/abstracts/middleware.d.ts +22 -0
- package/abstracts/middleware.js +8 -1
- package/abstracts/types.d.ts +64 -0
- package/abstracts/types.js +0 -14
- package/contexts/baseContext.d.ts +20 -0
- package/contexts/baseContext.js +17 -25
- package/contexts/connectionContext.d.ts +66 -0
- package/contexts/eventContext.d.ts +15 -0
- package/contexts/eventContext.js +5 -49
- package/contexts/joinContext.d.ts +17 -0
- package/contexts/joinContext.js +5 -54
- package/contexts/outgoingContext.d.ts +28 -0
- package/contexts/outgoingContext.js +3 -0
- package/engines/channelEngine.d.ts +26 -0
- package/engines/channelEngine.js +212 -192
- package/engines/endpointEngine.d.ts +34 -0
- package/engines/endpointEngine.js +15 -7
- package/engines/lobbyEngine.d.ts +54 -0
- package/engines/lobbyEngine.js +1 -1
- package/engines/presenceEngine.d.ts +15 -0
- package/engines/presenceEngine.js +6 -59
- package/errors/httpError.d.ts +6 -0
- package/errors/httpError.js +2 -0
- package/index.d.ts +14 -5
- package/index.js +37 -3
- package/matcher/matcher.d.ts +2 -0
- package/matcher/matcher.js +5 -5
- package/package.json +41 -18
- package/server/server.d.ts +21 -0
- package/server/server.js +48 -12
- package/types.d.ts +32 -621
- package/types.js +16 -0
- package/wrappers/channel.d.ts +54 -0
- package/wrappers/endpoint.d.ts +10 -0
- package/wrappers/pondChannel.d.ts +15 -0
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
|
+
}
|