mirror of
https://github.com/defold/extension-websocket.git
synced 2025-09-30 09:12:18 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f5aa57452f | ||
|
7e89b8a685 | ||
|
ba7454a431 | ||
|
b93a91c9b8 | ||
|
0bf63cbdf8 |
@@ -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 -ilo0 port 8080 ` (example for local ws:// connection)
|
||||||
|
|
||||||
* tcpdump: `sudo tcpdump -X -s0 host echo.websocket.org` (Monitors packets to/from echo.websocket.org)
|
* 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
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
- name: protocol
|
- name: protocol
|
||||||
type: string
|
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
|
- name: headers
|
||||||
type: string
|
type: string
|
||||||
|
@@ -509,6 +509,12 @@ static dmExtension::Result AppFinalize(dmExtension::AppParams* params)
|
|||||||
|
|
||||||
static dmExtension::Result Finalize(dmExtension::Params* 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;
|
return dmExtension::RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,12 +718,10 @@ static dmExtension::Result OnUpdate(dmExtension::Params* params)
|
|||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
conn->m_SSLSocket = dmSSLSocket::INVALID_SOCKET_HANDLE;
|
conn->m_SSLSocket = dmSSLSocket::INVALID_SOCKET_HANDLE;
|
||||||
|
|
||||||
if (conn->m_Protocol) {
|
EM_ASM({
|
||||||
EM_ASM({
|
// https://emscripten.org/docs/porting/networking.html#emulated-posix-tcp-sockets-over-websockets
|
||||||
// https://emscripten.org/docs/porting/networking.html#emulated-posix-tcp-sockets-over-websockets
|
Module["websocket"]["subprotocol"] = $0 ? UTF8ToString($0) : null;
|
||||||
Module["websocket"]["subprotocol"] = UTF8ToString($0);
|
}, conn->m_Protocol);
|
||||||
}, conn->m_Protocol);
|
|
||||||
}
|
|
||||||
|
|
||||||
char uri_buffer[dmURI::MAX_URI_LEN];
|
char uri_buffer[dmURI::MAX_URI_LEN];
|
||||||
const char* uri;
|
const char* uri;
|
||||||
|
Reference in New Issue
Block a user