@push.rocks/smartsocket 4.0.0 → 4.0.2
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/.smartconfig.json +38 -0
- package/dist_bundle/bundle.js +2405 -2157
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/smartsocket.classes.smartsocketclient.d.ts +3 -3
- package/dist_ts/smartsocket.classes.smartsocketclient.js +12 -8
- package/dist_ts/smartsocket.classes.socketconnection.d.ts +2 -2
- package/dist_ts/smartsocket.classes.socketconnection.js +9 -1
- package/dist_ts/smartsocket.classes.socketrequest.d.ts +1 -1
- package/dist_ts/smartsocket.classes.socketserver.js +9 -5
- package/dist_ts/smartsocket.plugins.d.ts +1 -2
- package/dist_ts/smartsocket.plugins.js +2 -3
- package/license +21 -0
- package/npmextra.json +14 -7
- package/package.json +16 -15
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/smartsocket.classes.smartsocketclient.ts +14 -10
- package/ts/smartsocket.classes.socketconnection.ts +10 -2
- package/ts/smartsocket.classes.socketrequest.ts +1 -1
- package/ts/smartsocket.classes.socketserver.ts +8 -6
- package/ts/smartsocket.plugins.ts +0 -2
|
@@ -22,7 +22,7 @@ export type TSocketConnectionSide = 'server' | 'client';
|
|
|
22
22
|
* interface for constructor of class SocketConnection
|
|
23
23
|
*/
|
|
24
24
|
export interface ISocketConnectionConstructorOptions {
|
|
25
|
-
alias
|
|
25
|
+
alias?: string;
|
|
26
26
|
authenticated: boolean;
|
|
27
27
|
side: TSocketConnectionSide;
|
|
28
28
|
smartsocketHost: Smartsocket | SmartsocketClient;
|
|
@@ -43,7 +43,7 @@ export let allSocketConnections = new plugins.lik.ObjectMap<SocketConnection>();
|
|
|
43
43
|
* class SocketConnection represents a websocket connection
|
|
44
44
|
*/
|
|
45
45
|
export class SocketConnection {
|
|
46
|
-
public alias
|
|
46
|
+
public alias?: string;
|
|
47
47
|
public side: TSocketConnectionSide;
|
|
48
48
|
public authenticated: boolean = false;
|
|
49
49
|
public smartsocketRef: Smartsocket | SmartsocketClient;
|
|
@@ -97,6 +97,10 @@ export class SocketConnection {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
private handleFunctionCall(messageData: interfaces.ISocketMessage<interfaces.IFunctionCallPayload>): void {
|
|
100
|
+
if (!messageData.id) {
|
|
101
|
+
logger.log('warn', 'received function call without request id');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
100
104
|
const requestData: ISocketRequestDataObject<any> = {
|
|
101
105
|
funcCallData: {
|
|
102
106
|
funcName: messageData.payload.funcName,
|
|
@@ -124,6 +128,10 @@ export class SocketConnection {
|
|
|
124
128
|
}
|
|
125
129
|
|
|
126
130
|
private handleFunctionResponse(messageData: interfaces.ISocketMessage<interfaces.IFunctionCallPayload>): void {
|
|
131
|
+
if (!messageData.id) {
|
|
132
|
+
logger.log('warn', 'received function response without request id');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
127
135
|
const responseData: ISocketRequestDataObject<any> = {
|
|
128
136
|
funcCallData: {
|
|
129
137
|
funcName: messageData.payload.funcName,
|
|
@@ -27,7 +27,7 @@ export interface ISocketRequestConstructorOptions<
|
|
|
27
27
|
side: TSocketRequestSide;
|
|
28
28
|
originSocketConnection: SocketConnection;
|
|
29
29
|
shortId: string;
|
|
30
|
-
funcCallData
|
|
30
|
+
funcCallData: ISocketFunctionCallDataRequest<T>;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -11,8 +11,8 @@ import { logger } from './smartsocket.logging.js';
|
|
|
11
11
|
*/
|
|
12
12
|
export class SocketServer {
|
|
13
13
|
private smartsocket: Smartsocket;
|
|
14
|
-
private httpServer: pluginsTyped.http.Server | pluginsTyped.https.Server;
|
|
15
|
-
private wsServer: pluginsTyped.ws.WebSocketServer;
|
|
14
|
+
private httpServer: pluginsTyped.http.Server | pluginsTyped.https.Server | null = null;
|
|
15
|
+
private wsServer: pluginsTyped.ws.WebSocketServer | null = null;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* whether httpServer is standalone (created by us)
|
|
@@ -38,17 +38,19 @@ export class SocketServer {
|
|
|
38
38
|
const httpModule = await this.smartsocket.smartenv.getSafeNodeModule('http');
|
|
39
39
|
const wsModule = await this.smartsocket.smartenv.getSafeNodeModule('ws');
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const httpServer = httpModule.createServer();
|
|
42
|
+
this.httpServer = httpServer;
|
|
42
43
|
this.standaloneServer = true;
|
|
43
44
|
|
|
44
45
|
// Create WebSocket server attached to HTTP server
|
|
45
|
-
|
|
46
|
+
const wsServer = new wsModule.WebSocketServer({ server: httpServer });
|
|
47
|
+
this.wsServer = wsServer;
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
wsServer.on('connection', (ws: pluginsTyped.ws.WebSocket) => {
|
|
48
50
|
this.smartsocket.handleNewConnection(ws);
|
|
49
51
|
});
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
httpServer.listen(this.smartsocket.options.port, () => {
|
|
52
54
|
logger.log(
|
|
53
55
|
'success',
|
|
54
56
|
`Server started in standalone mode on port ${this.smartsocket.options.port}`
|
|
@@ -4,7 +4,6 @@ import * as typedrequestInterfaces from '@api.global/typedrequest-interfaces';
|
|
|
4
4
|
export { typedrequestInterfaces };
|
|
5
5
|
|
|
6
6
|
// pushrocks scope
|
|
7
|
-
import * as isohash from '@push.rocks/isohash';
|
|
8
7
|
import * as isounique from '@push.rocks/isounique';
|
|
9
8
|
import * as lik from '@push.rocks/lik';
|
|
10
9
|
import * as smartenv from '@push.rocks/smartenv';
|
|
@@ -16,7 +15,6 @@ import * as smarttime from '@push.rocks/smarttime';
|
|
|
16
15
|
import * as smartrx from '@push.rocks/smartrx';
|
|
17
16
|
|
|
18
17
|
export {
|
|
19
|
-
isohash,
|
|
20
18
|
isounique,
|
|
21
19
|
lik,
|
|
22
20
|
smartenv,
|