File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -489,17 +489,10 @@ void WebSocketsServer::handleHeader(WSclient_t * client) {
489
489
}
490
490
491
491
} else {
492
- DEBUG_WEBSOCKETS (" [WS-Server][%d][handleHeader] no Websocket connection close.\n " , client->num );
493
- client->tcp .write (" HTTP/1.1 400 Bad Request\r\n "
494
- " Server: arduino-WebSocket-Server\r\n "
495
- " Content-Type: text/plain\r\n "
496
- " Content-Length: 32\r\n "
497
- " Connection: close\r\n "
498
- " Sec-WebSocket-Version: 13\r\n "
499
- " \r\n "
500
- " This is a Websocket server only!" );
501
- clientDisconnect (client);
492
+ handleNonWebsocketConnection (client);
502
493
}
503
494
}
504
495
}
505
496
497
+
498
+
Original file line number Diff line number Diff line change @@ -108,6 +108,24 @@ class WebSocketsServer: private WebSockets {
108
108
109
109
void handleHeader (WSclient_t * client);
110
110
111
+ /* *
112
+ * called if a non Websocket connection is comming in.
113
+ * Note: can be overrided
114
+ * @param client WSclient_t * ptr to the client struct
115
+ */
116
+ virtual void handleNonWebsocketConnection (WSclient_t * client) {
117
+ DEBUG_WEBSOCKETS (" [WS-Server][%d][handleHeader] no Websocket connection close.\n " , client->num );
118
+ client->tcp .write (" HTTP/1.1 400 Bad Request\r\n "
119
+ " Server: arduino-WebSocket-Server\r\n "
120
+ " Content-Type: text/plain\r\n "
121
+ " Content-Length: 32\r\n "
122
+ " Connection: close\r\n "
123
+ " Sec-WebSocket-Version: 13\r\n "
124
+ " \r\n "
125
+ " This is a Websocket server only!" );
126
+ clientDisconnect (client);
127
+ }
128
+
111
129
};
112
130
113
131
You can’t perform that action at this time.
0 commit comments