1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

minimal-ws-client: fix couple of breakages

This commit is contained in:
Andy Green 2018-12-17 19:09:13 +08:00
parent 30315ec688
commit 97aa696dc6
3 changed files with 7 additions and 3 deletions

View file

@ -18,6 +18,7 @@ Option|Meaning
--server|Use a specific server instead of libwebsockets.org, eg `--server localhost`. Implies LCCSCF_ALLOW_SELFSIGNED
--port|Use a specific port instead of 443, eg `--port 7681`
-z|Send zero-length pings for testing
--protocol|Use a specific ws subprotocol rather than lws-mirror-protocol, eg, `--protocol myprotocol`
## usage

View file

@ -19,7 +19,7 @@ static struct lws_context *context;
static struct lws *client_wsi;
static int interrupted, zero_length_ping, port = 443,
ssl_connection = LCCSCF_USE_SSL;
static const char *server_address = "libwebsockets.org", *pro = "lws-ping-test";
static const char *server_address = "libwebsockets.org", *pro = "lws-mirror-protocol";
struct pss {
int send_a_ping;
@ -40,7 +40,7 @@ connect_client(void)
i.origin = i.address;
i.ssl_connection = ssl_connection;
i.protocol = pro;
i.local_protocol_name = pro;
i.local_protocol_name = "lws-ping-test";
i.pwsi = &client_wsi;
return !lws_client_connect_via_info(&i);
@ -185,6 +185,9 @@ int main(int argc, const char **argv)
if (lws_cmdline_option(argc, argv, "-z"))
zero_length_ping = 1;
if ((p = lws_cmdline_option(argc, argv, "--protocol")))
pro = p;
if ((p = lws_cmdline_option(argc, argv, "--server"))) {
server_address = p;
pro = "lws-minimal";

View file

@ -249,7 +249,7 @@ skip:
* We respond by scheduling a writable callback for the
* connected client, if any.
*/
if (vhd->client_wsi && vhd->established)
if (vhd && vhd->client_wsi && vhd->established)
lws_callback_on_writable(vhd->client_wsi);
break;