Skip to content

Commit d047321

Browse files
committed
Update to the latest oatpp API version
1 parent a71fa8d commit d047321

File tree

11 files changed

+59
-59
lines changed

11 files changed

+59
-59
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
55
## use these variables to configure module installation
66

77
set(OATPP_THIS_MODULE_NAME oatpp-websocket) ## name of the module (also name of folders in installation dirs)
8-
set(OATPP_THIS_MODULE_VERSION "0.19.12") ## version of the module (also sufix of folders in installation dirs)
8+
set(OATPP_THIS_MODULE_VERSION "1.0.0") ## version of the module (also sufix of folders in installation dirs)
99
set(OATPP_THIS_MODULE_LIBRARIES oatpp-websocket) ## list of libraries to find when find_package is called
1010
set(OATPP_THIS_MODULE_TARGETS oatpp-websocket) ## list of targets to install
1111
set(OATPP_THIS_MODULE_DIRECTORIES oatpp-websocket) ## list of directories to install

src/oatpp-websocket/AsyncWebSocket.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ oatpp::async::CoroutineStarter AsyncWebSocket::readFrameHeaderAsync(const std::s
7575
std::shared_ptr<Frame::Header> m_frameHeader;
7676
private:
7777
v_int32 m_lenType;
78-
v_word16 m_bb;
79-
v_word16 m_messageLen2;
80-
v_word32 m_messageLen3 [2];
78+
v_uint16 m_bb;
79+
v_uint16 m_messageLen2;
80+
v_uint32 m_messageLen3 [2];
8181
private:
8282
oatpp::data::buffer::InlineReadData m_inlineData;
8383
public:
@@ -96,7 +96,7 @@ oatpp::async::CoroutineStarter AsyncWebSocket::readFrameHeaderAsync(const std::s
9696

9797
Action onBbRead() {
9898

99-
v_word8 messageLen1;
99+
v_uint8 messageLen1;
100100
Frame::unpackHeaderBits(ntohs(m_bb), *m_frameHeader, messageLen1);
101101

102102
if(messageLen1 < 126) {
@@ -126,7 +126,7 @@ oatpp::async::CoroutineStarter AsyncWebSocket::readFrameHeaderAsync(const std::s
126126
if(m_lenType == 2) {
127127
m_frameHeader->payloadLength = ntohs(m_messageLen2);
128128
} else if(m_lenType == 3) {
129-
m_frameHeader->payloadLength = (((v_word64) ntohl(m_messageLen3[0])) << 32) | ntohl(m_messageLen3[1]);
129+
m_frameHeader->payloadLength = (((v_uint64) ntohl(m_messageLen3[0])) << 32) | ntohl(m_messageLen3[1]);
130130
}
131131

132132
if(m_frameHeader->hasMask) {
@@ -157,10 +157,10 @@ oatpp::async::CoroutineStarter AsyncWebSocket::writeFrameHeaderAsync(const std::
157157
std::shared_ptr<Frame::Header> m_frameHeader;
158158
private:
159159
v_int32 m_lenType;
160-
v_word16 m_bb;
161-
v_word16 m_messageLen2;
162-
v_word32 m_messageLen3 [2];
163-
v_word8 m_messageLengthScenario;
160+
v_uint16 m_bb;
161+
v_uint16 m_messageLen2;
162+
v_uint32 m_messageLen3 [2];
163+
v_uint8 m_messageLengthScenario;
164164
private:
165165
oatpp::data::buffer::InlineWriteData m_inlineData;
166166
public:
@@ -393,7 +393,7 @@ oatpp::async::CoroutineStarter AsyncWebSocket::handleFrameAsync(const std::share
393393

394394
Action onClose() {
395395
if(m_listener) {
396-
v_word16 code = 0;
396+
v_uint16 code = 0;
397397
oatpp::String message;
398398
if(m_shortMessageStream->getSize() >= 2) {
399399
m_shortMessageStream->readSubstring(&code, 0, 2);
@@ -461,7 +461,7 @@ oatpp::async::CoroutineStarter AsyncWebSocket::listenAsync() {
461461
}
462462

463463
oatpp::async::CoroutineStarter AsyncWebSocket::sendFrameHeaderAsync(const std::shared_ptr<Frame::Header>& frameHeader,
464-
bool fin, v_word8 opcode, v_int64 messageSize)
464+
bool fin, v_uint8 opcode, v_int64 messageSize)
465465
{
466466

467467
frameHeader->fin = fin;
@@ -479,13 +479,13 @@ oatpp::async::CoroutineStarter AsyncWebSocket::sendFrameHeaderAsync(const std::s
479479
return writeFrameHeaderAsync(frameHeader);
480480
}
481481

482-
oatpp::async::CoroutineStarter AsyncWebSocket::sendOneFrameAsync(bool fin, v_word8 opcode, const oatpp::String& message) {
482+
oatpp::async::CoroutineStarter AsyncWebSocket::sendOneFrameAsync(bool fin, v_uint8 opcode, const oatpp::String& message) {
483483

484484
class SendFrameCoroutine : public oatpp::async::Coroutine<SendFrameCoroutine> {
485485
private:
486486
std::shared_ptr<AsyncWebSocket> m_socket;
487487
bool m_fin;
488-
v_word8 m_opcode;
488+
v_uint8 m_opcode;
489489
oatpp::String m_message;
490490
std::shared_ptr<Frame::Header> m_frameHeader;
491491
private:
@@ -494,7 +494,7 @@ oatpp::async::CoroutineStarter AsyncWebSocket::sendOneFrameAsync(bool fin, v_wor
494494
oatpp::data::buffer::InlineWriteData m_inlineData;
495495
public:
496496
SendFrameCoroutine(const std::shared_ptr<AsyncWebSocket>& socket,
497-
bool fin, v_word8 opcode, const oatpp::String& message)
497+
bool fin, v_uint8 opcode, const oatpp::String& message)
498498
: m_socket(socket)
499499
, m_fin(fin)
500500
, m_opcode(opcode)
@@ -539,7 +539,7 @@ oatpp::async::CoroutineStarter AsyncWebSocket::sendOneFrameAsync(bool fin, v_wor
539539

540540
}
541541

542-
oatpp::async::CoroutineStarter AsyncWebSocket::sendCloseAsync(v_word16 code, const oatpp::String& message) {
542+
oatpp::async::CoroutineStarter AsyncWebSocket::sendCloseAsync(v_uint16 code, const oatpp::String& message) {
543543

544544
code = htons(code);
545545

src/oatpp-websocket/AsyncWebSocket.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class AsyncWebSocket : public oatpp::base::Countable, public std::enable_shared_
101101
* @return - &id:oatpp::async::CoroutineStarter;. <br>
102102
* *To ignore this event return nullptr.*
103103
*/
104-
virtual CoroutineStarter onClose(const std::shared_ptr<AsyncWebSocket>& socket, v_word16 code, const oatpp::String& message) = 0;
104+
virtual CoroutineStarter onClose(const std::shared_ptr<AsyncWebSocket>& socket, v_uint16 code, const oatpp::String& message) = 0;
105105

106106
/**
107107
* Called when "text" or "binary" frame received. <br>
@@ -114,7 +114,7 @@ class AsyncWebSocket : public oatpp::base::Countable, public std::enable_shared_
114114
* @return - &id:oatpp::async::CoroutineStarter;. <br>
115115
* *To ignore this event return nullptr.*
116116
*/
117-
virtual CoroutineStarter readMessage(const std::shared_ptr<AsyncWebSocket>& socket, v_word8 opcode, p_char8 data, oatpp::v_io_size size) = 0;
117+
virtual CoroutineStarter readMessage(const std::shared_ptr<AsyncWebSocket>& socket, v_uint8 opcode, p_char8 data, oatpp::v_io_size size) = 0;
118118

119119
};
120120

@@ -238,7 +238,7 @@ class AsyncWebSocket : public oatpp::base::Countable, public std::enable_shared_
238238
* @param messageSize - size of the coming message.
239239
* @return - &id:oatpp::async::CoroutineStarter;.
240240
*/
241-
CoroutineStarter sendFrameHeaderAsync(const std::shared_ptr<Frame::Header>& frameHeader, bool fin, v_word8 opcode, v_int64 messageSize);
241+
CoroutineStarter sendFrameHeaderAsync(const std::shared_ptr<Frame::Header>& frameHeader, bool fin, v_uint8 opcode, v_int64 messageSize);
242242

243243
/**
244244
* Send one frame message with custom fin and opcode.
@@ -247,15 +247,15 @@ class AsyncWebSocket : public oatpp::base::Countable, public std::enable_shared_
247247
* @param message - message text. &id:oatpp::String;.
248248
* @return - &id:oatpp::async::CoroutineStarter;.
249249
*/
250-
CoroutineStarter sendOneFrameAsync(bool fin, v_word8 opcode, const oatpp::String& message);
250+
CoroutineStarter sendOneFrameAsync(bool fin, v_uint8 opcode, const oatpp::String& message);
251251

252252
/**
253253
* Send close frame.
254254
* @param code - code of the websocket connection close message.
255255
* @param message - message text. &id:oatpp::String;.
256256
* @return - &id:oatpp::async::Action;.
257257
*/
258-
CoroutineStarter sendCloseAsync(v_word16 code, const oatpp::String& message);
258+
CoroutineStarter sendCloseAsync(v_uint16 code, const oatpp::String& message);
259259

260260
/**
261261
* Send close frame without message.

src/oatpp-websocket/Frame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
namespace oatpp { namespace websocket {
2828

29-
void Frame::packHeaderBits(v_word16& bits, const Header& frameHeader, v_word8& messageLengthScenario) {
29+
void Frame::packHeaderBits(v_uint16& bits, const Header& frameHeader, v_uint8& messageLengthScenario) {
3030

3131
bits = 0;
3232

@@ -52,7 +52,7 @@ void Frame::packHeaderBits(v_word16& bits, const Header& frameHeader, v_word8& m
5252

5353
}
5454

55-
void Frame::unpackHeaderBits(v_word16 bits, Header& frameHeader, v_word8& messageLen1) {
55+
void Frame::unpackHeaderBits(v_uint16 bits, Header& frameHeader, v_uint8& messageLen1) {
5656
frameHeader.fin = (bits & 32768) > 0; // 32768
5757
frameHeader.rsv1 = (bits & 16384) > 0; // 16384
5858
frameHeader.rsv2 = (bits & 8192) > 0; // 8192

src/oatpp-websocket/Frame.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,32 @@ class Frame {
3838
/**
3939
* Continuation frame.
4040
*/
41-
static constexpr v_word8 OPCODE_CONTINUATION = 0x0;
41+
static constexpr v_uint8 OPCODE_CONTINUATION = 0x0;
4242

4343
/**
4444
* Text frame.
4545
*/
46-
static constexpr v_word8 OPCODE_TEXT = 0x1;
46+
static constexpr v_uint8 OPCODE_TEXT = 0x1;
4747

4848
/**
4949
* Binary frame.
5050
*/
51-
static constexpr v_word8 OPCODE_BINARY = 0x2;
51+
static constexpr v_uint8 OPCODE_BINARY = 0x2;
5252

5353
/**
5454
* Close frame.
5555
*/
56-
static constexpr v_word8 OPCODE_CLOSE = 0x8;
56+
static constexpr v_uint8 OPCODE_CLOSE = 0x8;
5757

5858
/**
5959
* Ping frame.
6060
*/
61-
static constexpr v_word8 OPCODE_PING = 0x9;
61+
static constexpr v_uint8 OPCODE_PING = 0x9;
6262

6363
/**
6464
* Pong frame.
6565
*/
66-
static constexpr v_word8 OPCODE_PONG = 0xA;
66+
static constexpr v_uint8 OPCODE_PONG = 0xA;
6767

6868
public:
6969

@@ -94,7 +94,7 @@ class Frame {
9494
/**
9595
* Operation code.
9696
*/
97-
v_word8 opcode;
97+
v_uint8 opcode;
9898

9999
/**
100100
* Mask bit. For client-to-server messages should be `true`. For server-to-client messages should be `false`.
@@ -109,7 +109,7 @@ class Frame {
109109
/**
110110
* Payload mask.
111111
*/
112-
v_word8 mask[4] = {0, 0, 0, 0};
112+
v_uint8 mask[4] = {0, 0, 0, 0};
113113
};
114114

115115
public:
@@ -121,15 +121,15 @@ class Frame {
121121
* @param messageLengthScenario - out parameter. Depending on message length scenario. Message length can be encoded
122122
* in 1, 2, or 8 bytes.
123123
*/
124-
static void packHeaderBits(v_word16& bits, const Header& frameHeader, v_word8& messageLengthScenario);
124+
static void packHeaderBits(v_uint16& bits, const Header& frameHeader, v_uint8& messageLengthScenario);
125125

126126
/**
127127
* Deserialize &l:Frame::Header;.
128128
* @param bits - two bytes header.
129129
* @param frameHeader - out parameter. &l:Frame::Header;.
130130
* @param messageLen1 - first byte of encoded message length.
131131
*/
132-
static void unpackHeaderBits(v_word16 bits, Header& frameHeader, v_word8& messageLen1);
132+
static void unpackHeaderBits(v_uint16 bits, Header& frameHeader, v_uint8& messageLen1);
133133

134134
};
135135

src/oatpp-websocket/WebSocket.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,31 @@ bool WebSocket::checkForContinuation(const Frame::Header& frameHeader) {
6969

7070
void WebSocket::readFrameHeader(Frame::Header& frameHeader) const {
7171

72-
v_word16 bb;
72+
v_uint16 bb;
7373
auto res = m_connection->readExactSizeDataSimple(&bb, 2);
7474
if(res != 2) {
7575
throw std::runtime_error("[oatpp::web::protocol::websocket::WebSocket::readFrameHeader()]: Error reading frame header");
7676
}
7777

78-
v_word8 messageLen1;
78+
v_uint8 messageLen1;
7979
Frame::unpackHeaderBits(ntohs(bb), frameHeader, messageLen1);
8080

8181
if(messageLen1 < 126) {
8282
frameHeader.payloadLength = messageLen1;
8383
} else if(messageLen1 == 126) {
84-
v_word16 messageLen2;
84+
v_uint16 messageLen2;
8585
res = m_connection->readExactSizeDataSimple(&messageLen2, 2);
8686
if(res != 2) {
8787
throw std::runtime_error("[oatpp::web::protocol::websocket::WebSocket::readFrameHeader()]: Error reading frame header. Reading payload length scenario 2.");
8888
}
8989
frameHeader.payloadLength = ntohs(messageLen2);
9090
} else if(messageLen1 == 127) {
91-
v_word32 messageLen3[2];
91+
v_uint32 messageLen3[2];
9292
res = m_connection->readExactSizeDataSimple(&messageLen3, 8);
9393
if(res != 8) {
9494
throw std::runtime_error("[oatpp::web::protocol::websocket::WebSocket::readFrameHeader()]: Error reading frame header. Reading payload length scenario 3.");
9595
}
96-
frameHeader.payloadLength = (((v_word64) ntohl(messageLen3[0])) << 32) | ntohl(messageLen3[1]);
96+
frameHeader.payloadLength = (((v_uint64) ntohl(messageLen3[0])) << 32) | ntohl(messageLen3[1]);
9797
}
9898

9999
if(frameHeader.hasMask) {
@@ -107,8 +107,8 @@ void WebSocket::readFrameHeader(Frame::Header& frameHeader) const {
107107

108108
void WebSocket::writeFrameHeader(const Frame::Header& frameHeader) const {
109109

110-
v_word16 bb;
111-
v_word8 messageLengthScenario;
110+
v_uint16 bb;
111+
v_uint8 messageLengthScenario;
112112
Frame::packHeaderBits(bb, frameHeader, messageLengthScenario);
113113

114114
bb = htons(bb);
@@ -119,13 +119,13 @@ void WebSocket::writeFrameHeader(const Frame::Header& frameHeader) const {
119119
}
120120

121121
if(messageLengthScenario == 2) {
122-
v_word16 messageLen2 = htons(frameHeader.payloadLength);
122+
v_uint16 messageLen2 = htons(frameHeader.payloadLength);
123123
res = m_connection->writeExactSizeDataSimple(&messageLen2, 2);
124124
if(res != 2) {
125125
throw std::runtime_error("[oatpp::web::protocol::websocket::WebSocket::writeFrameHeader()]: Error writing frame header. Writing payload length scenario 2.");
126126
}
127127
} else if(messageLengthScenario == 3) {
128-
v_word32 messageLen3[2];
128+
v_uint32 messageLen3[2];
129129
messageLen3[0] = htonl(frameHeader.payloadLength >> 32);
130130
messageLen3[1] = htonl(frameHeader.payloadLength & 0xFFFFFFFF);
131131
res = m_connection->writeExactSizeDataSimple(&messageLen3, 8);
@@ -230,7 +230,7 @@ void WebSocket::handleFrame(const Frame::Header& frameHeader) {
230230
oatpp::data::stream::ChunkedBuffer messageStream;
231231
readPayload(frameHeader, &messageStream);
232232
if(m_listener) {
233-
v_word16 code = 0;
233+
v_uint16 code = 0;
234234
oatpp::String message;
235235
if(messageStream.getSize() >= 2) {
236236
messageStream.readSubstring(&code, 0, 2);
@@ -299,7 +299,7 @@ void WebSocket::stopListening() const {
299299
m_listening = false;
300300
}
301301

302-
void WebSocket::sendFrameHeader(Frame::Header& frameHeader, bool fin, v_word8 opcode, v_int64 messageSize) const {
302+
void WebSocket::sendFrameHeader(Frame::Header& frameHeader, bool fin, v_uint8 opcode, v_int64 messageSize) const {
303303
frameHeader.fin = fin;
304304
frameHeader.rsv1 = false;
305305
frameHeader.rsv2 = false;
@@ -315,7 +315,7 @@ void WebSocket::sendFrameHeader(Frame::Header& frameHeader, bool fin, v_word8 op
315315
writeFrameHeader(frameHeader);
316316
}
317317

318-
bool WebSocket::sendOneFrame(bool fin, v_word8 opcode, const oatpp::String& message) const {
318+
bool WebSocket::sendOneFrame(bool fin, v_uint8 opcode, const oatpp::String& message) const {
319319
Frame::Header frameHeader;
320320
if(message && message->getSize() > 0) {
321321
sendFrameHeader(frameHeader, fin, opcode, message->getSize());
@@ -338,7 +338,7 @@ bool WebSocket::sendOneFrame(bool fin, v_word8 opcode, const oatpp::String& mess
338338
return true;
339339
}
340340

341-
void WebSocket::sendClose(v_word16 code, const oatpp::String& message) const {
341+
void WebSocket::sendClose(v_uint16 code, const oatpp::String& message) const {
342342

343343
code = htons(code);
344344

src/oatpp-websocket/WebSocket.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class WebSocket : public oatpp::base::Countable {
7474
* @param code - close frame message code.
7575
* @param message - message text; &id:oatpp::String;.
7676
*/
77-
virtual void onClose(const WebSocket& socket, v_word16 code, const oatpp::String& message) = 0;
77+
virtual void onClose(const WebSocket& socket, v_uint16 code, const oatpp::String& message) = 0;
7878

7979
/**
8080
* Called when "text" or "binary" frame received. <br>
@@ -85,7 +85,7 @@ class WebSocket : public oatpp::base::Countable {
8585
* @param data - pointer to message data.
8686
* @param size - data size.
8787
*/
88-
virtual void readMessage(const WebSocket& socket, v_word8 opcode, p_char8 data, oatpp::v_io_size size) = 0;
88+
virtual void readMessage(const WebSocket& socket, v_uint8 opcode, p_char8 data, oatpp::v_io_size size) = 0;
8989

9090
};
9191

@@ -217,7 +217,7 @@ class WebSocket : public oatpp::base::Countable {
217217
* @param opcode - operation code.
218218
* @param messageSize - coming message size.
219219
*/
220-
void sendFrameHeader(Frame::Header& frameHeader, bool fin, v_word8 opcode, v_int64 messageSize) const;
220+
void sendFrameHeader(Frame::Header& frameHeader, bool fin, v_uint8 opcode, v_int64 messageSize) const;
221221

222222
/**
223223
* Send one frame message with custom fin and opcode.
@@ -227,15 +227,15 @@ class WebSocket : public oatpp::base::Countable {
227227
* @return - `true` on success, `false` on error.
228228
* if `false` returned socket should be closed manually.
229229
*/
230-
bool sendOneFrame(bool fin, v_word8 opcode, const oatpp::String& message) const;
230+
bool sendOneFrame(bool fin, v_uint8 opcode, const oatpp::String& message) const;
231231

232232
/**
233233
* Send close frame.
234234
* @param code - close message code.
235235
* @param message - message text. &id:oatpp::String;.
236236
* @throws - `runtime_error`.
237237
*/
238-
void sendClose(v_word16 code, const oatpp::String& message) const;
238+
void sendClose(v_uint16 code, const oatpp::String& message) const;
239239

240240
/**
241241
* Send close frame without message.

0 commit comments

Comments
 (0)