Skip to content
Snippets Groups Projects
Commit 993343b5 authored by David Brooks's avatar David Brooks Committed by Andy Green
Browse files

set connection callback before connection completed to allow early messages


Signed-off-by: default avatarDavid Brooks <dave@bcs.co.nz>
Signed-off-by: default avatarAndy Green <andy@warmcat.com>
--

 lib/client-handshake.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
parent 6c6a3d3c
No related branches found
No related tags found
No related merge requests found
...@@ -241,14 +241,33 @@ libwebsocket_client_connect(struct libwebsocket_context *context, ...@@ -241,14 +241,33 @@ libwebsocket_client_connect(struct libwebsocket_context *context,
} else } else
wsi->c_origin = NULL; wsi->c_origin = NULL;
wsi->c_callback = NULL;
if (protocol) { if (protocol) {
const char *pc;
struct libwebsocket_protocols *pp;
wsi->c_protocol = malloc(strlen(protocol) + 1); wsi->c_protocol = malloc(strlen(protocol) + 1);
if (wsi->c_protocol == NULL) if (wsi->c_protocol == NULL)
goto oom3; goto oom3;
strcpy(wsi->c_protocol, protocol); strcpy(wsi->c_protocol, protocol);
pc = protocol;
while (*pc && *pc != ',')
pc++;
n = pc - protocol;
pp = context->protocols;
while (pp->name && !wsi->c_callback) {
if (!strncmp(protocol, pp->name, n))
wsi->c_callback = pp->callback;
pp++;
}
} else } else
wsi->c_protocol = NULL; wsi->c_protocol = NULL;
if (!wsi->c_callback)
wsi->c_callback = context->protocols[0].callback;
/* set up appropriate masking */ /* set up appropriate masking */
wsi->xor_mask = xor_no_mask; wsi->xor_mask = xor_no_mask;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment