mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
исправляем библиотеку сокетов для работы с фреймами
This commit is contained in:
@@ -225,13 +225,17 @@ bool WebSocketsServerCore::broadcastTXT(String & payload) {
|
||||
* @param headerToPayload bool (see sendFrame for more details)
|
||||
* @return true if ok
|
||||
*/
|
||||
bool WebSocketsServerCore::sendBIN(uint8_t num, uint8_t * payload, size_t length, bool fin, bool headerToPayload) {
|
||||
bool WebSocketsServerCore::sendBIN(uint8_t num, uint8_t * payload, size_t length, bool fin, bool continuation, bool headerToPayload) {
|
||||
if(num >= WEBSOCKETS_SERVER_CLIENT_MAX) {
|
||||
return false;
|
||||
}
|
||||
WSclient_t * client = &_clients[num];
|
||||
if(clientIsConnected(client)) {
|
||||
return sendFrame(client, WSop_binary, payload, length, fin, headerToPayload);
|
||||
if(continuation) {
|
||||
return sendFrame(client, WSop_continuation, payload, length, fin, headerToPayload);
|
||||
} else {
|
||||
return sendFrame(client, WSop_binary, payload, length, fin, headerToPayload);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class WebSocketsServerCore : protected WebSockets {
|
||||
bool broadcastTXT(const char * payload, size_t length = 0);
|
||||
bool broadcastTXT(String & payload);
|
||||
|
||||
bool sendBIN(uint8_t num, uint8_t * payload, size_t length, bool fin = true, bool headerToPayload = false);
|
||||
bool sendBIN(uint8_t num, uint8_t * payload, size_t length, bool fin = true, bool continuation = false, bool headerToPayload = false);
|
||||
bool sendBIN(uint8_t num, const uint8_t * payload, size_t length);
|
||||
|
||||
bool broadcastBIN(uint8_t * payload, size_t length, bool fin = true, bool headerToPayload = false);
|
||||
|
||||
@@ -433,15 +433,23 @@ void sendBlobToWsStrHeader(const String& filename, const String& header, uint8_t
|
||||
size_t payloadSize = file.read(payloadBuf, maxPayloadSize);
|
||||
if (payloadSize) {
|
||||
size_t size = headerSize + payloadSize;
|
||||
|
||||
bool fin = false;
|
||||
if (i == 16) {
|
||||
fin = true;
|
||||
} else {
|
||||
if (size == frameSize) {
|
||||
fin = false;
|
||||
} else {
|
||||
fin = true;
|
||||
}
|
||||
|
||||
SerialPrint("I", "FS", String(size) + " " + String(fin) + " " + String(i));
|
||||
standWebSocket.sendBIN(client_id, frameBuf, size, fin);
|
||||
bool continuation = false;
|
||||
if (i == 0) {
|
||||
continuation = false;
|
||||
} else {
|
||||
continuation = true;
|
||||
}
|
||||
|
||||
SerialPrint("I", "FS", String(i) + ") sz: " + String(size) + " fin: " + String(fin) + " cnt: " + String(continuation));
|
||||
standWebSocket.sendBIN(client_id, frameBuf, size, fin, continuation);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user