mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-12-22 23:13:00 +01:00
Compare commits
3 Commits
2.7.1
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24f36a78d1 | ||
|
|
84f379474d | ||
|
|
6801736f98 |
2
.github/workflows/arduino-lint.yaml
vendored
2
.github/workflows/arduino-lint.yaml
vendored
@@ -4,7 +4,7 @@ jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: arduino/arduino-lint-action@v2
|
||||
with:
|
||||
library-manager: update
|
||||
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
- name: WiFiNINA
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Compile examples
|
||||
uses: arduino/compile-sketches@v1
|
||||
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Compile examples
|
||||
uses: arduino/compile-sketches@v1
|
||||
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Compile examples
|
||||
uses: arduino/compile-sketches@v1
|
||||
|
||||
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
check_version_files:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: check version
|
||||
run: |
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
prepare_example_json:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: generate examples
|
||||
id: set-matrix
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
ARDUINO_DIRECTORIES_DATA: /home/runner/arduino_ide
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Get hash
|
||||
id: get-hash
|
||||
@@ -116,7 +116,7 @@ jobs:
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: install libgtk2.0-0
|
||||
run: |
|
||||
|
||||
@@ -478,6 +478,19 @@ bool WebSocketsClient::isConnected(void) {
|
||||
return (_client.status == WSC_CONNECTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 6455
|
||||
* get the full URL/URI of the connection
|
||||
*/
|
||||
String WebSocketsClient::getUrl(void) {
|
||||
#if defined(HAS_SSL)
|
||||
String protocol = (_client.isSSL) ? WEBSOCKETS_STRING("wss://") : WEBSOCKETS_STRING("ws://");
|
||||
#else
|
||||
String protocol = WEBSOCKETS_STRING("ws://");
|
||||
#endif
|
||||
return protocol + _host + ":" + String(_port) + _client.cUrl;
|
||||
}
|
||||
|
||||
// #################################################################################
|
||||
// #################################################################################
|
||||
// #################################################################################
|
||||
@@ -519,10 +532,11 @@ void WebSocketsClient::messageReceived(WSclient_t * client, WSopcode_t opcode, u
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect an client
|
||||
* Disconnect a client
|
||||
* @param client WSclient_t * ptr to the client struct
|
||||
* @param reason const char * disconnect reason (optional, defaults to NULL)
|
||||
*/
|
||||
void WebSocketsClient::clientDisconnect(WSclient_t * client) {
|
||||
void WebSocketsClient::clientDisconnect(WSclient_t * client, const char * reason) {
|
||||
bool event = false;
|
||||
|
||||
#ifdef HAS_SSL
|
||||
@@ -571,7 +585,11 @@ void WebSocketsClient::clientDisconnect(WSclient_t * client) {
|
||||
|
||||
DEBUG_WEBSOCKETS("[WS-Client] client disconnected.\n");
|
||||
if(event) {
|
||||
runCbEvent(WStype_DISCONNECTED, NULL, 0);
|
||||
if(reason && strlen(reason) > 0) {
|
||||
runCbEvent(WStype_DISCONNECTED, (uint8_t *)reason, strlen(reason));
|
||||
} else {
|
||||
runCbEvent(WStype_DISCONNECTED, NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,13 +612,13 @@ bool WebSocketsClient::clientIsConnected(WSclient_t * client) {
|
||||
if(client->status != WSC_NOT_CONNECTED) {
|
||||
DEBUG_WEBSOCKETS("[WS-Client] connection lost.\n");
|
||||
// do cleanup
|
||||
clientDisconnect(client);
|
||||
clientDisconnect(client, "Connection lost");
|
||||
}
|
||||
}
|
||||
|
||||
if(client->tcp) {
|
||||
// do cleanup
|
||||
clientDisconnect(client);
|
||||
clientDisconnect(client, "TCP connection cleanup");
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -612,7 +630,7 @@ bool WebSocketsClient::clientIsConnected(WSclient_t * client) {
|
||||
void WebSocketsClient::handleClientData(void) {
|
||||
if((_client.status == WSC_HEADER || _client.status == WSC_BODY) && _lastHeaderSent + WEBSOCKETS_TCP_TIMEOUT < millis()) {
|
||||
DEBUG_WEBSOCKETS("[WS-Client][handleClientData] header response timeout.. disconnecting!\n");
|
||||
clientDisconnect(&_client);
|
||||
clientDisconnect(&_client, "Header response timeout");
|
||||
WEBSOCKETS_YIELD();
|
||||
return;
|
||||
}
|
||||
@@ -847,7 +865,9 @@ void WebSocketsClient::handleHeader(WSclient_t * client, String * headerLine) {
|
||||
default: ///< Server dont unterstand requrst
|
||||
ok = false;
|
||||
DEBUG_WEBSOCKETS("[WS-Client][handleHeader] serverCode is not 101 (%d)\n", client->cCode);
|
||||
clientDisconnect(client);
|
||||
// Create disconnect reason with HTTP status code
|
||||
String reason = "HTTP " + String(client->cCode);
|
||||
clientDisconnect(client, reason.c_str());
|
||||
_lastConnectionFail = millis();
|
||||
break;
|
||||
}
|
||||
@@ -891,7 +911,11 @@ void WebSocketsClient::handleHeader(WSclient_t * client, String * headerLine) {
|
||||
if(clientIsConnected(client)) {
|
||||
write(client, "This is a webSocket client!");
|
||||
}
|
||||
clientDisconnect(client);
|
||||
String reason = "WebSocket handshake failed";
|
||||
if(client->cCode > 0) {
|
||||
reason += " - HTTP " + String(client->cCode);
|
||||
}
|
||||
clientDisconnect(client, reason.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ class WebSocketsClient : protected WebSockets {
|
||||
void disableHeartbeat();
|
||||
|
||||
bool isConnected(void);
|
||||
String getUrl(void);
|
||||
|
||||
protected:
|
||||
String _host;
|
||||
@@ -156,7 +157,10 @@ class WebSocketsClient : protected WebSockets {
|
||||
|
||||
void messageReceived(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length, bool fin);
|
||||
|
||||
void clientDisconnect(WSclient_t * client);
|
||||
void clientDisconnect(WSclient_t * client) {
|
||||
clientDisconnect(client, NULL);
|
||||
}
|
||||
void clientDisconnect(WSclient_t * client, const char * reason = NULL);
|
||||
bool clientIsConnected(WSclient_t * client);
|
||||
|
||||
#if (WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC)
|
||||
|
||||
Reference in New Issue
Block a user