5 Commits
1.5.0 ... 1.5.2

Author SHA1 Message Date
Björn Ritzl
f5aa57452f Merge pull request #26 from defold/Issue-25-crash-in-callback
Destroy connections when finalizing the extension
2020-12-22 12:21:20 +01:00
Björn Ritzl
7e89b8a685 Destroy connections when finalizing the extension 2020-12-22 12:19:12 +01:00
Mathias Westerdahl
ba7454a431 Merge pull request #24 from defold/issue-22-skip-protocol-by-default
Issue 22: Don't send Sec-WebSocket-Protocol unless specified
2020-11-10 08:42:30 +01:00
JCash
b93a91c9b8 Issue 22: Don't send Sec-WebSocket-Protocol unless specified 2020-11-09 19:03:27 +01:00
Mathias Westerdahl
0bf63cbdf8 Added credit and link to wslay 2020-11-01 09:28:27 +01:00
3 changed files with 17 additions and 7 deletions

View File

@@ -40,3 +40,9 @@ For command line debugging, there's
* tcpdump: `sudo tcpdump -X -s0 -ilo0 port 8080 ` (example for local ws:// connection)
* tcpdump: `sudo tcpdump -X -s0 host echo.websocket.org` (Monitors packets to/from echo.websocket.org)
## Credits
This extension makes use of the C library WSlay by @tatsuhiro-t:
* https://github.com/tatsuhiro-t/wslay

View File

@@ -23,7 +23,7 @@
- name: protocol
type: string
desc: the protocol to use (e.g. 'chat'). (Default is 'binary')
desc: the protocol to use (e.g. 'chat'). If not set, no `Sec-WebSocket-Protocol` header is sent.
- name: headers
type: string

View File

@@ -509,6 +509,12 @@ static dmExtension::Result AppFinalize(dmExtension::AppParams* params)
static dmExtension::Result Finalize(dmExtension::Params* params)
{
while (!g_Websocket.m_Connections.Empty())
{
WebsocketConnection* conn = g_Websocket.m_Connections.Back();
g_Websocket.m_Connections.Pop();
DestroyConnection(conn);
}
return dmExtension::RESULT_OK;
}
@@ -712,12 +718,10 @@ static dmExtension::Result OnUpdate(dmExtension::Params* params)
#if defined(__EMSCRIPTEN__)
conn->m_SSLSocket = dmSSLSocket::INVALID_SOCKET_HANDLE;
if (conn->m_Protocol) {
EM_ASM({
// https://emscripten.org/docs/porting/networking.html#emulated-posix-tcp-sockets-over-websockets
Module["websocket"]["subprotocol"] = UTF8ToString($0);
Module["websocket"]["subprotocol"] = $0 ? UTF8ToString($0) : null;
}, conn->m_Protocol);
}
char uri_buffer[dmURI::MAX_URI_LEN];
const char* uri;