-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 8: Handle the websocket close event #9
Conversation
* `0` to disable debugging (i.e. no debug output). | ||
* `1` to display state changes. | ||
* `2` to display the messages sent and received. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to have for the users to be able to debug what's happening.
@@ -20,10 +20,13 @@ local function websocket_callback(self, conn, data) | |||
print("Connected " .. conn) | |||
-- self.connection = conn | |||
elseif data.event == websocket.EVENT_ERROR then | |||
print("Error:", data.error) | |||
print("Error:", data.message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Api change: All events now have the "message".
lua_setfield(L, -2, "message"); | ||
} | ||
lua_pushlstring(L, conn->m_Buffer + msg_offset, msg_length); | ||
lua_setfield(L, -2, "message"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easier to reason about (and thus remember)
@@ -94,7 +86,7 @@ ssize_t WSL_RecvCallback(wslay_event_context_ptr ctx, uint8_t *buf, size_t len, | |||
dmSocket::Result socket_result = Receive(conn, buf, len, &r); | |||
|
|||
if (dmSocket::RESULT_OK == socket_result && r == 0) | |||
socket_result = dmSocket::RESULT_WOULDBLOCK; | |||
socket_result = dmSocket::RESULT_CONNABORTED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, when the server does an abnormal exit (1006), we don't get that message, and we'd just wait forever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
No description provided.