feat:add some logs and terminate actions
This commit is contained in:
parent
1d6a2d8828
commit
f721713615
@ -29,10 +29,22 @@ export async function createServer() {
|
|||||||
ws.on('message', async function (result: string) {
|
ws.on('message', async function (result: string) {
|
||||||
const resultObject = JSON.parse(result) as MSG
|
const resultObject = JSON.parse(result) as MSG
|
||||||
if (resultObject.type === "D2C") {
|
if (resultObject.type === "D2C") {
|
||||||
|
console.log("D2C", wss.clients.size, client)
|
||||||
if (client === undefined) {
|
if (client === undefined) {
|
||||||
wss?.clients.forEach(e => {
|
if (wss.clients.size <= 1) {
|
||||||
|
debug?.send(JSON.stringify({
|
||||||
|
type: "S2D",
|
||||||
|
cmd: "DEBUG_STOP",
|
||||||
|
payload: {
|
||||||
|
msg: "No devices connected.",
|
||||||
|
}
|
||||||
|
} as MSG));
|
||||||
|
console.log("Debugger need at least one connected device.")
|
||||||
|
} else {
|
||||||
|
wss.clients.forEach(e => {
|
||||||
e.send(result);
|
e.send(result);
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
client.send(result);
|
client.send(result);
|
||||||
}
|
}
|
||||||
@ -114,7 +126,10 @@ export async function createServer() {
|
|||||||
console.log("quit debugging");
|
console.log("quit debugging");
|
||||||
client?.send(JSON.stringify({
|
client?.send(JSON.stringify({
|
||||||
type: "S2C",
|
type: "S2C",
|
||||||
cmd: "DEBUG_STOP"
|
cmd: "DEBUG_STOP",
|
||||||
|
payload: {
|
||||||
|
msg: "Debugger quit",
|
||||||
|
}
|
||||||
} as MSG));
|
} as MSG));
|
||||||
}
|
}
|
||||||
if (ws === client) {
|
if (ws === client) {
|
||||||
@ -122,7 +137,10 @@ export async function createServer() {
|
|||||||
client = undefined;
|
client = undefined;
|
||||||
debug?.send(JSON.stringify({
|
debug?.send(JSON.stringify({
|
||||||
type: "S2D",
|
type: "S2D",
|
||||||
cmd: "DEBUG_STOP"
|
cmd: "DEBUG_STOP",
|
||||||
|
payload: {
|
||||||
|
msg: "Debugging device quit",
|
||||||
|
}
|
||||||
} as MSG));
|
} as MSG));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user