8000 Merge pull request #698 from toxuin/websocket-types · usmandroid/esp32-snippets@e4ce7da · GitHub
[go: up one dir, main page]

Skip to content

Commit e4ce7da

Browse files
authored
Merge pull request nkolban#698 from toxuin/websocket-types
WebSocket: Opcodes are uint8_t
2 parents 9d2d2ed + 871a946 commit e4ce7da

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cpp_utils/WebSocket.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ extern "C" {
2121
static const char* LOG_TAG = "WebSocket";
2222

2323
// WebSocket op codes as found in a WebSocket frame.
24-
static const int OPCODE_CONTINUE = 0x00;
25-
static const int OPCODE_TEXT = 0x01;
26-
static const int OPCODE_BINARY = 0x02;
27-
static const int OPCODE_CLOSE = 0x08;
28-
static const int OPCODE_PING = 0x09;
29-
static const int OPCODE_PONG = 0x0a;
24+
static const uint8_t OPCODE_CONTINUE = 0x00;
25+
static const uint8_t OPCODE_TEXT = 0x01;
26+
static const uint8_t OPCODE_BINARY = 0x02;
27+
static const uint8_t OPCODE_CLOSE = 0x08;
28+
static const uint8_t OPCODE_PING = 0x09;
29+
static const uint8_t OPCODE_PONG = 0x0a;
3030

3131

3232
// Structure definition for the WebSocket frame.
@@ -119,7 +119,7 @@ class WebSocketReader: public Task {
119119
break;
120120
}
121121
ESP_LOGD("WebSocketReader", "Waiting on socket data for socket %s", peerSocket.toString().c_str());
122-
int length = peerSocket.receive((uint8_t*)&frame, sizeof(frame), true); // Read exact
122+
size_t length = peerSocket.receive((uint8_t*)&frame, sizeof(frame), true); // Read exact
123123
if (length != sizeof(frame)) {
124124
ESP_LOGD(LOG_TAG, "Socket read error");
125125
pWebSocket->close();
@@ -476,7 +476,7 @@ WebSocketInputStreambuf::int_type WebSocketInputStreambuf::underflow() {
476476
// We wish to refill the buffer. We want to read data from the socket. We want to read either
477477
// the size of the buffer to fill it or the maximum number of bytes remaining to be read.
478478
// We will choose which ever is smaller as the number of bytes to read into the buffer.
479-
int remainingBytes = getRecordSize()-m_sizeRead;
479+
size_t remainingBytes = getRecordSize()-m_sizeRead;
480480
size_t sizeToRead;
481481
if (remainingBytes < m_bufferSize) {
482482
sizeToRead = remainingBytes;
@@ -485,7 +485,7 @@ WebSocketInputStreambuf::int_type WebSocketInputStreambuf::underflow() {
485485
}
486486

487487
ESP_LOGD("WebSocketInputRecordStreambuf", "- getting next buffer of data; size request: %d", sizeToRead);
488-
int bytesRead = m_socket.receive((uint8_t*)m_buffer, sizeToRead, true);
488+
size_t bytesRead = m_socket.receive((uint8_t*)m_buffer, sizeToRead, true);
489489
if (bytesRead == 0) {
490490
ESP_LOGD("WebSocketInputRecordStreambuf", "<< underflow: Read 0 bytes");
491491
return EOF;

0 commit comments

Comments
 (0)
0