Branch: Tag:

2018-10-02

2018-10-02 10:00:49 by Henrik Grubbström (Grubba) <grubba@grubba.org>

WebSocket [Example]: Signal issues to the client.

It should now be possible for clients to detect whether the
module was happy with a message or not.

69:    if (ws->id->misc->ws_id && ws->id->misc->ws_id != ws_id) {    werror("Wrong WebSocket ID! Expected %d and got %d\n",    ws->id->misc->ws_id, ws_id); +  ws->close();    return;    }       if (ws->id->misc->ws_cnt >= cnt) {    werror("Messages out of order. Last cnt %d, got %d\n",    ws->id->misc->ws_cnt, cnt); -  +  ws->close();    return;    }       ws->id->misc->ws_id = ws_id;    ws->id->misc->ws_cnt = cnt;    -  +  // NB: Reverses the order! +  ws->send_text(sprintf("%d %d", cnt, ws_id)); +     if (!random(10)) {    // Close a random connection    // id->websocket_close();    }   }