<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi,<br>
<br>
first of all, thank you very much for giving the world a decent
WebSockets library in C. That made my life so much easier!<br>
<br>
Unfortunately though, there seems to be a glitch where after a
couple of seconds of continuous runtime a frame arrives at my
program, where<br>
<br>
nopoll_msg_get_payload(msg); // returns an empty string<br>
nopoll_msg_get_payload_size(msg); // returns 1<br>
<br>
in my callback.<br>
<br>
If I choose to silently ignore this event, then the following frames
are corrupted, reporting invalid data.<br>
<br>
This usually happens only when my app is on very high traffic, and
has run for about a minute.<br>
<br>
Can you help me find out what's going wrong, or point me in the
right direction where to look?<br>
<br>
Thank you, and kind Regards,<br>
Andreas<br>
<br>
<br>
Below is my main function, and my callback:<br>
<br>
void<br>
botframe_callback (noPollCtx *ctx, noPollConn *conn, noPollMsg *msg,
noPollPtr *user_data)<br>
{<br>
if (nopoll_msg_is_fragment(msg))<br>
{<br>
printf("oh, I got a fragment!\n");<br>
return;<br>
}<br>
<br>
char *message = nopoll_msg_get_payload(msg);<br>
unsigned int length = nopoll_msg_get_payload_size(msg);<br>
<br>
if (length <= 1)<br>
{<br>
printf("that's not a message!\n");<br>
return;<br>
}<br>
<br>
// after this point, there is a lot of json parsing, and data
management<br>
// somewhere in the middle of it, I send a response:<br>
<br>
nopoll_conn_send_text (conn, str, strlen(str));<br>
<br>
// and then there is some more stuff, and resource releasing code<br>
}<br>
<br>
<br>
<font face="Courier New, Courier, monospace">int<br>
main (void)<br>
{<br>
noPollCtx *ctx = nopoll_ctx_new();<br>
if (!ctx)<br>
{<br>
perror("unable to create websocket context");<br>
exit(1);<br>
}<br>
<br>
nopoll_ctx_set_on_msg(ctx,
(noPollOnMessageHandler)&botframe_callback, NULL);<br>
<br>
noPollConn *conn = nopoll_conn_new(ctx, "localhost", "8080",
NULL, NULL, NULL, NULL);<br>
if (!nopoll_conn_is_ok(conn))<br>
{<br>
perror("unable to connect to cow server");<br>
exit(1);<br>
}<br>
<br>
nopoll_loop_wait(ctx, 0);<br>
<br>
return 0;<br>
}</font><br>
</body>
</html>