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

clean fraggle

Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
Andy Green 2011-03-08 08:43:59 +00:00
parent e9739ed203
commit 98a623fa46
2 changed files with 51 additions and 15 deletions

View file

@ -166,6 +166,50 @@ another server, you can specify the protcol to handshake with
by --protocol=protocolname
Fraggle test app
----------------
By default it runs in server mode
$ libwebsockets-test-fraggle
libwebsockets test fraggle
(C) Copyright 2010-2011 Andy Green <andy@warmcat.com> licensed under LGPL2.1
Compiled with SSL support, not using it
Listening on port 7681
server sees client connect
accepted v06 connection
Spamming 360 random fragments
Spamming session over, len = 371913. sum = 0x2D3C0AE
Spamming 895 random fragments
Spamming session over, len = 875970. sum = 0x6A74DA1
...
You need to run a second session in client mode, you have to
give the -c switch and the server address at least:
$ libwebsockets-test-fraggle -c localhost
libwebsockets test fraggle
(C) Copyright 2010-2011 Andy Green <andy@warmcat.com> licensed under LGPL2.1
Client mode
Connecting to localhost:7681
denied deflate-stream extension
handshake OK for protocol fraggle-protocol
client connects to server
EOM received 371913 correctly from 360 fragments
EOM received 875970 correctly from 895 fragments
EOM received 247140 correctly from 258 fragments
EOM received 695451 correctly from 692 fragments
...
The fraggle test sends a random number up to 1024 fragmented websocket frames
each of a random size between 1 and 2001 bytes in a single message, then sends
a checksum and starts sending a new randomly sized and fragmented message.
The fraggle test client receives the same message fragments and computes the
same checksum using websocket framing to see when the message has ended. It
then accepts the server checksum message and compares that to its checksum.
proxy support
-------------

View file

@ -41,14 +41,6 @@ enum demo_protocols {
/* fraggle protocol */
/*
* one of these is auto-created for each connection and a pointer to the
* appropriate instance is passed to the callback in the user parameter
*
* for this example protocol we use it to individualize the count for each
* connection.
*/
struct per_session_data__fraggle {
int packets_left;
int total_message;
@ -111,7 +103,7 @@ callback_fraggle(struct libwebsocket_context * context,
psf->sum = 0;
psf->total_message = 0;
psf->packets_left = 0;
// fprintf(stderr, "starting receiving a message\n");
/* fallthru */
case 1:
@ -139,13 +131,13 @@ callback_fraggle(struct libwebsocket_context * context,
"len = %d. sum = 0x%lX\n",
psf->total_message, psf->sum);
buf[LWS_SEND_BUFFER_PRE_PADDING + 0] = psf->sum >> 24;
buf[LWS_SEND_BUFFER_PRE_PADDING + 1] = psf->sum >> 16;
buf[LWS_SEND_BUFFER_PRE_PADDING + 2] = psf->sum >> 8;
buf[LWS_SEND_BUFFER_PRE_PADDING + 3] = psf->sum;
p[0] = psf->sum >> 24;
p[1] = psf->sum >> 16;
p[2] = psf->sum >> 8;
p[3] = psf->sum;
n = libwebsocket_write(wsi, (unsigned char *)
&buf[LWS_SEND_BUFFER_PRE_PADDING], 4, LWS_WRITE_TEXT);
n = libwebsocket_write(wsi, (unsigned char *)p,
4, LWS_WRITE_TEXT);
libwebsocket_callback_on_writable(context, wsi);