| 61 | } |
| 62 | |
| 63 | void wsMessageReceived(WebsocketConnection& socket, const String& message) |
| 64 | { |
| 65 | Serial.println(_F("WebSocket message received:")); |
| 66 | Serial.println(message); |
| 67 | |
| 68 | if(message == _F("shutdown")) { |
| 69 | String reply(F("The server is shutting down...")); |
| 70 | socket.broadcast(reply); |
| 71 | shutdownServer(); |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | String response = F("Echo: ") + message; |
| 76 | socket.sendString(response); |
| 77 | |
| 78 | // Normally you would use dynamic cast but just be careful not to convert to wrong object type! |
| 79 | auto user = static_cast<CUserData*>(socket.getUserData()); |
| 80 | if(user != nullptr) { |
| 81 | user->printMessage(socket, message); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | #ifdef ENABLE_CMD_HANDLER |
| 86 | void wsCommandReceived(WebsocketConnection& socket, const String& message) |
nothing calls this directly
no test coverage detected