File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
#include <stdio.h>
2
2
#include <stdlib.h>
3
3
#include <emscripten/websocket.h>
4
+ #include <assert.h>
4
5
5
6
EM_BOOL WebSocketOpen (int eventType , const EmscriptenWebSocketOpenEvent * e , void * userData )
6
7
{
@@ -73,7 +74,8 @@ int main()
73
74
EmscriptenWebSocketCreateAttributes attr ;
74
75
emscripten_websocket_init_create_attributes (& attr );
75
76
76
- attr .url = "ws://localhost:8088" ;
77
+ const char * url = "ws://localhost:8088/" ;
78
+ attr .url = url ;
77
79
78
80
EMSCRIPTEN_WEBSOCKET_T socket = emscripten_websocket_new (& attr );
79
81
if (socket <= 0 )
@@ -82,6 +84,11 @@ int main()
82
84
exit (1 );
83
85
}
84
86
87
+ int urlLength = 0 ;
88
+ EMSCRIPTEN_RESULT res = emscripten_websocket_get_url_length (socket , & urlLength );
89
+ assert (res == EMSCRIPTEN_RESULT_SUCCESS );
90
+ assert (urlLength == strlen (url ));
91
+
85
92
emscripten_websocket_set_onopen_callback (socket , (void * )42 , WebSocketOpen );
86
93
emscripten_websocket_set_onclose_callback (socket , (void * )43 , WebSocketClose );
87
94
emscripten_websocket_set_onerror_callback (socket , (void * )44 , WebSocketError );
You can’t perform that action at this time.
0 commit comments