alemonjs 2.1.39 → 2.1.40
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/lib/cbp/server/main.js +21 -0
- package/lib/process/ipc-bridge.js +10 -0
- package/package.json +1 -1
package/lib/cbp/server/main.js
CHANGED
|
@@ -10,6 +10,7 @@ import 'yaml';
|
|
|
10
10
|
import '../../core/utils.js';
|
|
11
11
|
import { USER_AGENT_HEADER, USER_AGENT_HEADER_VALUE_MAP, DEVICE_ID_HEADER, FULL_RECEIVE_HEADER, platformClient, childrenClient, fullClient, childrenBind, clientBindCount, unbindClient, bindChannelToClient } from '../processor/config.js';
|
|
12
12
|
import { createTestOneController } from './testone.js';
|
|
13
|
+
import { getClientChild } from '../../process/ipc-bridge.js';
|
|
13
14
|
|
|
14
15
|
const routeMessageToDevice = (DeviceId, message) => {
|
|
15
16
|
if (childrenClient.has(DeviceId)) {
|
|
@@ -30,8 +31,28 @@ const routeMessageToDevice = (DeviceId, message) => {
|
|
|
30
31
|
fullClient.delete(DeviceId);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
34
|
+
else {
|
|
35
|
+
const clientChild = getClientChild();
|
|
36
|
+
if (clientChild?.connected) {
|
|
37
|
+
try {
|
|
38
|
+
const parsed = flattedJSON.parse(String(message));
|
|
39
|
+
clientChild.send({ type: 'ipc:data', data: parsed });
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
33
45
|
};
|
|
34
46
|
const handleEvent = (message, ID) => {
|
|
47
|
+
const clientChild = getClientChild();
|
|
48
|
+
if (clientChild?.connected) {
|
|
49
|
+
try {
|
|
50
|
+
const parsed = flattedJSON.parse(String(message));
|
|
51
|
+
clientChild.send({ type: 'ipc:data', data: parsed });
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
35
56
|
fullClient.forEach((clientWs, clientId) => {
|
|
36
57
|
if (clientWs.readyState === WebSocket.OPEN) {
|
|
37
58
|
clientWs.send(message);
|
|
@@ -36,6 +36,16 @@ const forwardFromClient = (data) => {
|
|
|
36
36
|
if (platformChild?.connected) {
|
|
37
37
|
platformChild.send({ type: 'ipc:data', data });
|
|
38
38
|
}
|
|
39
|
+
if (global.__sandbox && global.testoneClient) {
|
|
40
|
+
try {
|
|
41
|
+
const messageStr = typeof data === 'string' ? data : flattedJSON.stringify(data);
|
|
42
|
+
if (global.testoneClient.readyState === WebSocket.OPEN) {
|
|
43
|
+
global.testoneClient.send(messageStr);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
39
49
|
};
|
|
40
50
|
|
|
41
51
|
export { forwardFromClient, forwardFromPlatform, getClientChild, getPlatformChild, setClientChild, setPlatformChild };
|