Skip to content

Commit e8f6a6f

Browse files
committed
fixlose message send
1 parent 5dd4e47 commit e8f6a6f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

include/internal/WebSocketProtocol.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ namespace SL {
6060
if (socket->SocketStatus_ == SocketStatus::CONNECTED) {
6161
//only send messages if the socket is in a connected state
6262
write(parent, socket, msg.msg);
63+
//update the socket status to reflect it is closing to prevent other messages from being sent.. this is the last valid message
64+
//make sure to do this after a call to write so the write process sends the close message, but no others
65+
if (msg.code == OpCode::CLOSE) {
66+
socket->SocketStatus_ = SocketStatus::CLOSING;
67+
}
6368
}
6469
}
6570
else {
@@ -77,11 +82,6 @@ namespace SL {
7782
if (socket->SendMessageQueue.size() == 1) {
7883
SL::WS_LITE::startwrite(parent, socket);
7984
}
80-
//update the socket status to reflect it is closing to prevent other messages from being sent.. this is the last valid message
81-
//make sure to do this after a call to startwrite so the write process sends the close message, but no others
82-
if (msg.code == OpCode::CLOSE) {
83-
socket->SocketStatus_ = SocketStatus::CLOSING;
84-
}
8585
}
8686
});
8787
}

0 commit comments

Comments
 (0)