pi-web 0.3.6 → 0.3.8
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/build/server/server.js
CHANGED
|
@@ -58,7 +58,7 @@ const server = createServer((req, res) => {
|
|
|
58
58
|
if (req.url === "/" || req.url === "/index.html") {
|
|
59
59
|
if (!existsSync(htmlPath)) {
|
|
60
60
|
res.writeHead(503, { "Content-Type": "text/plain" });
|
|
61
|
-
res.end("
|
|
61
|
+
res.end("frontend not built. run: npm run build");
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
@@ -120,7 +120,7 @@ const server = createServer((req, res) => {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
123
|
-
res.end("
|
|
123
|
+
res.end("not found");
|
|
124
124
|
});
|
|
125
125
|
const wss = new WebSocketServer({ server });
|
|
126
126
|
const rpcSessions = new Map();
|
|
@@ -159,7 +159,7 @@ wss.on("connection", (ws) => {
|
|
|
159
159
|
if (msg.type === "rpc_command") {
|
|
160
160
|
const rpc = rpcSessions.get(ws);
|
|
161
161
|
if (!rpc) {
|
|
162
|
-
ws.send(JSON.stringify({ type: "error", message: "
|
|
162
|
+
ws.send(JSON.stringify({ type: "error", message: "no active session" }));
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
rpc.send(msg.command);
|