API CHANGE: ws.close -> ws.end, ws.terminate -> ws.close
This commit is contained in:
+4
-7
@@ -48,6 +48,9 @@ public:
|
||||
/* See AsyncSocket */
|
||||
using Super::getBufferedAmount;
|
||||
|
||||
/* Simple, immediate close of the socket. Emits close event */
|
||||
using Super::close;
|
||||
|
||||
/* Send or buffer a WebSocket frame, compressed or not. Returns false on increased user space backpressure. */
|
||||
bool send(std::string_view message, uWS::OpCode opCode = uWS::OpCode::BINARY, bool compress = false) {
|
||||
/* Transform the message to compressed domain if requested */
|
||||
@@ -87,7 +90,7 @@ public:
|
||||
}
|
||||
|
||||
/* Send websocket close frame, emit close event, send FIN if successful */
|
||||
void close(int code, std::string_view message = {}) {
|
||||
void end(int code, std::string_view message = {}) {
|
||||
/* Check if we already called this one */
|
||||
WebSocketData *webSocketData = (WebSocketData *) us_new_socket_ext(SSL, (us_new_socket_t *) this);
|
||||
if (webSocketData->isShuttingDown) {
|
||||
@@ -122,12 +125,6 @@ public:
|
||||
webSocketContextData->closeHandler(this, code, message);
|
||||
}
|
||||
}
|
||||
|
||||
/* Simple, immediate close of the socket. Emits close event */
|
||||
void terminate() {
|
||||
/* This calls close event in context where it checks for isShuttingDown and either emits websocket close or not */
|
||||
Super::close();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ private:
|
||||
if (!remainingBytes && fin && !webSocketData->controlTipLength) {
|
||||
if (opCode == CLOSE) {
|
||||
auto closeFrame = protocol::parseClosePayload(data, length);
|
||||
webSocket->close(closeFrame.code, std::string_view(closeFrame.message, closeFrame.length));
|
||||
webSocket->end(closeFrame.code, std::string_view(closeFrame.message, closeFrame.length));
|
||||
return true;
|
||||
} else {
|
||||
if (opCode == PING) {
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
char *controlBuffer = (char *) webSocketData->fragmentBuffer.data() + webSocketData->fragmentBuffer.length() - webSocketData->controlTipLength;
|
||||
if (opCode == CLOSE) {
|
||||
protocol::CloseFrame closeFrame = protocol::parseClosePayload(controlBuffer, webSocketData->controlTipLength);
|
||||
webSocket->close(closeFrame.code, std::string_view(closeFrame.message, closeFrame.length));
|
||||
webSocket->end(closeFrame.code, std::string_view(closeFrame.message, closeFrame.length));
|
||||
return true;
|
||||
} else {
|
||||
if (opCode == PING) {
|
||||
|
||||
Reference in New Issue
Block a user