@push.rocks/smartsocket 4.0.0 → 4.0.1
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 +2359 -1857
- 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/license +21 -0
- package/npmextra.json +14 -7
- package/package.json +22 -19
- 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
|
@@ -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}`
|