@@ -558,20 +558,23 @@ static bool cmpheader(const char *buf, const char *name, const char *value) {
558558}
559559
560560static void wcb (struct mg_connection * c , int ev , void * ev_data , void * fn_data ) {
561+ int * p = (int * ) fn_data ;
561562 if (ev == MG_EV_WS_OPEN ) {
562563 struct mg_http_message * hm = (struct mg_http_message * ) ev_data ;
563564 struct mg_str * wsproto = mg_http_get_header (hm , "Sec-WebSocket-Protocol" );
564565 ASSERT (wsproto != NULL );
565566 mg_ws_send (c , "boo" , 3 , WEBSOCKET_OP_BINARY );
567+ mg_ws_send (c , "foobar" , 6 , WEBSOCKET_OP_BINARY );
566568 mg_ws_send (c , "" , 0 , WEBSOCKET_OP_PING );
567- (( int * ) fn_data ) [0 ] += 100 ;
569+ p [0 ] += 100 ;
568570 } else if (ev == MG_EV_WS_MSG ) {
569571 struct mg_ws_message * wm = (struct mg_ws_message * ) ev_data ;
570- if (mg_strstr (wm -> data , mg_str ("boo " )))
572+ if (mg_strstr (wm -> data , mg_str ("foobar " )))
571573 mg_ws_send (c , "" , 0 , WEBSOCKET_OP_CLOSE );
572- ((int * ) fn_data )[0 ]++ ;
574+ if (mg_strstr (wm -> data , mg_str ("boo" ))) p [0 ] += 2 ;
575+ if (mg_strstr (wm -> data , mg_str ("foobar" ))) p [0 ] += 3 ;
573576 } else if (ev == MG_EV_CLOSE ) {
574- (( int * ) fn_data ) [0 ] += 10 ;
577+ p [0 ] += 10 ;
575578 }
576579}
577580
@@ -586,7 +589,7 @@ static void test_ws(void) {
586589 mg_ws_connect (& mgr , url , wcb , & done , "%s" , "Sec-WebSocket-Protocol: meh\r\n" );
587590 for (i = 0 ; i < 30 ; i ++ ) mg_mgr_poll (& mgr , 1 );
588591 // MG_INFO(("--> %d", done));
589- ASSERT (done == 112 );
592+ ASSERT (done == 115 );
590593
591594 // Test that non-WS requests fail
592595 ASSERT (fetch (& mgr , buf , url , "GET /ws HTTP/1.0\r\n\n" ) == 426 );
0 commit comments