Skip to content

Commit 3f8cb77

Browse files
authored
fix: proper quote handle without external Internet
1 parent 21528f3 commit 3f8cb77

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

ViInvaders.ino

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
#include <ArduinoJson.h>
77

88
// External network (Internet)
9-
const char* ssid_sta = "NetworkName";
10-
const char* password_sta = "SecretPassword";
9+
// const char* ssid_sta = "NetworkName";
10+
// const char* password_sta = "SecretPassword";
1111

1212
// Local AP (for players)
1313
const char* ssid = "ViInvaders";
1414
const char* password = "editorwar";
1515

16-
// static AP ip conf
16+
// Static IP for Access Point
1717
IPAddress apIP(192, 168, 4, 1);
1818
IPAddress apNetmask(255, 255, 255, 0);
1919
IPAddress apGateway(192, 168, 4, 1);
2020

2121
// WebServer WebSocket
2222
AsyncWebServer server(80);
23-
AsyncWebSocket ws("/ws");
23+
AsyncWebSocket ws("/ws"); // websocket endpoint
2424

25-
// joystick pinout config
25+
// joystick pinout
2626
#define JOY1_X 34
2727
#define JOY1_SW 25
2828
#define JOY2_X 35
@@ -136,16 +136,11 @@ void setup() {
136136
if (SPIFFS.exists(quoteCachePath)) {
137137
request->send(SPIFFS, quoteCachePath, "application/json");
138138
} else {
139-
StaticJsonDocument<192> doc;
140-
doc["content"] = "No internet. Stay sharp, Commander!";
141-
doc["author"] = "ESP32";
142-
String out;
143-
serializeJson(doc, out);
144-
request->send(200, "application/json", out);
139+
request->send(409);
145140
}
146141
});
147142

148-
143+
// WebSocket
149144
ws.onEvent(onWsEvent);
150145
server.addHandler(&ws);
151146

data/game.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ canvas.addEventListener("touchstart", (e) => {
517517

518518

519519
function setupWebSocket() {
520-
ws = new WebSocket("ws://" + location.hostname + "/ws");
521-
// ws = new WebSocket("ws://192.168.4.1/ws");
520+
// ws = new WebSocket("ws://" + location.hostname + "/ws");
521+
ws = new WebSocket("ws://192.168.4.1/ws");
522522

523523
ws.onmessage = (event) => {
524524
const data = JSON.parse(event.data);

0 commit comments

Comments
 (0)