MCPcopy Create free account
hub / github.com/SmingHub/Sming / wsMessageReceived

Function wsMessageReceived

samples/HttpServer_WebSockets/app/application.cpp:63–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void 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
86void wsCommandReceived(WebsocketConnection& socket, const String& message)

Callers

nothing calls this directly

Calls 7

shutdownServerFunction · 0.85
printlnMethod · 0.80
getUserDataMethod · 0.80
printMessageMethod · 0.80
FFunction · 0.50
broadcastMethod · 0.45
sendStringMethod · 0.45

Tested by

no test coverage detected