more fixes, works now (atleast without auth)

This commit is contained in:
Franzi 2021-12-05 15:23:39 +01:00
parent bd411ce2ba
commit 070364018e
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -1,4 +1,4 @@
#define LED_COUNT 19 #define LED_COUNT 10
#define LED_BRIGHTNESS 100 #define LED_BRIGHTNESS 100
#define LED_PIN 12 #define LED_PIN 12
@ -79,9 +79,6 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
// Find out if we need authentication // Find out if we need authentication
#ifdef OBS_PASS #ifdef OBS_PASS
webSocket.sendTXT("{\"request-type\":\"GetAuthRequired\",\"message-id\":\"1\"}"); webSocket.sendTXT("{\"request-type\":\"GetAuthRequired\",\"message-id\":\"1\"}");
#else
webSocket.sendTXT("{\"request-type\":\"GetCurrentScene\",\"message-id\":\"1\"}");
webSocket.sendTXT("{\"request-type\":\"GetPreviewScene\",\"message-id\":\"2\"}");
#endif #endif
break; break;
@ -137,16 +134,16 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
webSocket.sendTXT(authRequest); webSocket.sendTXT(authRequest);
break; break;
} else if (doc.containsKey("message-id") && (doc["message-id"]) == "2") { } else if (doc.containsKey("message-id") && doc["message-id"] == "2") {
if (strcmp(doc["status"], "ok") == 0) { if (strcmp(doc["status"], "ok") == 0) {
Serial.println("[OBS] authentication successful"); Serial.println("[OBS] authentication successful");
} else { } else {
Serial.println("Authenticated FAILED"); Serial.println("[OBS] authentication FAILED");
set_error(); set_error();
} }
break; break;
} }
# endif #endif
if (doc.containsKey("update-type")) { if (doc.containsKey("update-type")) {
bool my_source_in_current_event = false; bool my_source_in_current_event = false;
@ -157,13 +154,13 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
} }
} }
if (strcmp(doc["update-type"], "SwitchScenes") == 0 || strcmp(doc["update-type"], "GetCurrentScene") == 0) { if (strcmp(doc["update-type"], "SwitchScenes") == 0) {
if (my_source_in_current_event) { if (my_source_in_current_event) {
is_currently_live = true; is_currently_live = true;
} else { } else {
is_currently_live = false; is_currently_live = false;
} }
} else if (strcmp(doc["update-type"], "PreviewSceneChanged") == 0 || strcmp(doc["update-type"], "GetPreviewScene") == 0) { } else if (strcmp(doc["update-type"], "PreviewSceneChanged") == 0) {
if (my_source_in_current_event) { if (my_source_in_current_event) {
is_currently_preview = true; is_currently_preview = true;
} else { } else {
@ -186,14 +183,9 @@ void handleWebSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
} }
} }
case WStype_BIN:
case WStype_ERROR:
case WStype_FRAGMENT_TEXT_START:
case WStype_FRAGMENT_BIN_START:
case WStype_FRAGMENT:
case WStype_FRAGMENT_FIN:
case WStype_PING: case WStype_PING:
case WStype_PONG: case WStype_PONG:
Serial.println("[WS] ping/pong");
break; break;
} }
} }