Added status code to callback when the server closes the connection (#45)

* Added WebSocket close code to callback

Also added message and code for HTML5

* Unify disconnect handling for wslay and html5
This commit is contained in:
Björn Ritzl
2022-06-23 20:52:46 +02:00
committed by GitHub
parent 5c5736d8bc
commit 24bb291c72
7 changed files with 40 additions and 25 deletions

View File

@@ -61,6 +61,14 @@
type: string
desc: The received data if event is `websocket.EVENT_MESSAGE`. Error message otherwise
- name: handshake_response
type: table
desc: Handshake response information (status, headers etc)
- name: code
type: number
desc: Status code received from the server if the server closed the connection. Only present if event is `EVENT_DISCONNECTED`.
returns:
- name: connection
@@ -86,7 +94,7 @@
end
function init(self)
self.url = "ws://echo.websocket.org"
self.url = "ws://echo.websocket.events"
local params = {
timeout = 3000,
headers = "Sec-WebSocket-Protocol: chat\r\nOrigin: mydomain.com\r\n"