@eleven-am/pondsocket 0.1.45 → 0.1.47
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/client.js +1 -2
- package/package.json +1 -1
- package/types.d.ts +15 -21
- package/enums.d.ts +0 -48
package/client.js
CHANGED
|
@@ -65,8 +65,7 @@ class PondClient {
|
|
|
65
65
|
* @param params - The params to send to the server.
|
|
66
66
|
*/
|
|
67
67
|
createChannel(name, params) {
|
|
68
|
-
|
|
69
|
-
if (((_a = this._channels[name]) === null || _a === void 0 ? void 0 : _a.channelState) !== enums_1.ChannelState.CLOSED) {
|
|
68
|
+
if (this._channels[name] && this._channels[name].channelState !== enums_1.ChannelState.CLOSED) {
|
|
70
69
|
return this._channels[name];
|
|
71
70
|
}
|
|
72
71
|
const publisher = this._createPublisher();
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ import internal from 'stream';
|
|
|
5
5
|
import { Express } from 'express';
|
|
6
6
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
7
7
|
|
|
8
|
-
import { ClientActions, PresenceEventTypes, ChannelState } from './enums';
|
|
9
|
-
|
|
10
8
|
export type PondPath = string | RegExp;
|
|
11
9
|
type NextFunction = () => void;
|
|
12
10
|
export type JoinParams = Record<string, any>;
|
|
@@ -17,27 +15,24 @@ export type EndpointHandler = (req: IncomingConnection, res: ConnectionResponse)
|
|
|
17
15
|
type SocketCache = Pick<RequestCache, 'socket' | 'clientId' | 'assigns'>;
|
|
18
16
|
type AuthorizeMiddleware = (request: JoinRequest, response: JoinResponse) => void | Promise<void>;
|
|
19
17
|
type SocketMiddlewareFunction = (req: IncomingMessage, socket: internal.Duplex, head: Buffer, next: NextFunction) => void;
|
|
20
|
-
export type ChannelReceivers = 'all_users' | 'all_except_sender' | string[];
|
|
21
|
-
export type ChannelEvent = Event | PresenceEvent;
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
channelName: string;
|
|
19
|
+
declare enum ClientActions {
|
|
20
|
+
JOIN_CHANNEL = 'JOIN_CHANNEL',
|
|
21
|
+
LEAVE_CHANNEL = 'LEAVE_CHANNEL',
|
|
22
|
+
BROADCAST = 'BROADCAST',
|
|
28
23
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
addresses?: ChannelReceivers;
|
|
24
|
+
declare enum PondState {
|
|
25
|
+
CONNECTING = 'CONNECTING',
|
|
26
|
+
OPEN = 'OPEN',
|
|
27
|
+
CLOSING = 'CLOSING',
|
|
28
|
+
CLOSED = 'CLOSED',
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
declare enum ChannelState {
|
|
31
|
+
IDLE = 'IDLE',
|
|
32
|
+
JOINING = 'JOINING',
|
|
33
|
+
JOINED = 'JOINED',
|
|
34
|
+
STALLED = 'STALLED',
|
|
35
|
+
CLOSED = 'CLOSED',
|
|
41
36
|
}
|
|
42
37
|
interface RequestCache {
|
|
43
38
|
clientId: string;
|
|
@@ -104,7 +99,6 @@ interface PondSocketExpressApp extends Express {
|
|
|
104
99
|
*/
|
|
105
100
|
upgrade(path: PondPath, handler: EndpointHandler): Endpoint;
|
|
106
101
|
}
|
|
107
|
-
export type PondState = 'CONNECTING' | 'OPEN' | 'CLOSING' | 'CLOSED';
|
|
108
102
|
type Unsubscribe = () => void;
|
|
109
103
|
|
|
110
104
|
export interface PresencePayload {
|
package/enums.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export enum PresenceEventTypes {
|
|
2
|
-
JOIN = 'JOIN',
|
|
3
|
-
LEAVE = 'LEAVE',
|
|
4
|
-
UPDATE = 'UPDATE'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export enum ServerActions {
|
|
8
|
-
PRESENCE = 'PRESENCE',
|
|
9
|
-
SYSTEM = 'SYSTEM',
|
|
10
|
-
BROADCAST = 'BROADCAST',
|
|
11
|
-
ERROR = 'ERROR',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export enum ClientActions {
|
|
15
|
-
JOIN_CHANNEL = 'JOIN_CHANNEL',
|
|
16
|
-
LEAVE_CHANNEL = 'LEAVE_CHANNEL',
|
|
17
|
-
BROADCAST = 'BROADCAST',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export enum PondState {
|
|
21
|
-
CONNECTING = 'CONNECTING',
|
|
22
|
-
OPEN = 'OPEN',
|
|
23
|
-
CLOSING = 'CLOSING',
|
|
24
|
-
CLOSED = 'CLOSED',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export enum ChannelState {
|
|
28
|
-
IDLE = 'IDLE',
|
|
29
|
-
JOINING = 'JOINING',
|
|
30
|
-
JOINED = 'JOINED',
|
|
31
|
-
STALLED = 'STALLED',
|
|
32
|
-
CLOSED = 'CLOSED',
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export enum ErrorTypes {
|
|
36
|
-
UNAUTHORIZED_JOIN_REQUEST = 'UNAUTHORIZED_JOIN_REQUEST',
|
|
37
|
-
UNAUTHORIZED_BROADCAST = 'UNAUTHORIZED_BROADCAST',
|
|
38
|
-
INVALID_MESSAGE = 'INVALID_MESSAGE',
|
|
39
|
-
HANDLER_NOT_FOUND = 'HANDLER_NOT_FOUND',
|
|
40
|
-
PRESENCE_LEAVE_FAILED = 'PRESENCE_LEAVE_FAILED',
|
|
41
|
-
INTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR',
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export enum SystemSender {
|
|
45
|
-
SERVER = 'SERVER',
|
|
46
|
-
ENDPOINT = 'ENDPOINT',
|
|
47
|
-
CHANNEL = 'CHANNEL',
|
|
48
|
-
}
|