mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-10-10 04:25:25 +00:00
socket 调试
This commit is contained in:
32
electron-app/test/cmd.js
Normal file
32
electron-app/test/cmd.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// 游戏的inspect脚本
|
||||
const host = "192.168.1.5";//"localhost";
|
||||
const port = 1109;
|
||||
let url = `ws://${host}:${port}`;
|
||||
const ws = new WebSocket(url);
|
||||
ws.onopen = () => {
|
||||
console.log("成功链接调试服务器", url);
|
||||
};
|
||||
ws.onmessage = (event) => {
|
||||
console.log("收到消息", event);
|
||||
const {code} = JSON.parse(event.data);
|
||||
if (code) {
|
||||
let ret = null;
|
||||
let error = false;
|
||||
try {
|
||||
ret = eval(`${code}`);
|
||||
} catch (e) {
|
||||
error = true;
|
||||
ret = e.toString();
|
||||
}
|
||||
ws.send(JSON.stringify({
|
||||
error,
|
||||
data: ret,
|
||||
}));
|
||||
}
|
||||
};
|
||||
ws.onerror = () => {
|
||||
console.log("error");
|
||||
};
|
||||
ws.onclose = () => {
|
||||
console.log("close");
|
||||
};
|
11
electron-app/test/index.html
Normal file
11
electron-app/test/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<script src="cmd.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user