A WebSocket++ based server listens for HTTP (or HTTPS for secure WebSocket servers) connections as well as WebSocket ones. By default, such requests get an HTTP error response with status code 426/Upgrade required. A WebSocket++ endpoint may implement an http_handler instead to process these requests.
Example blocking http_handler
Example non-blocking http_handler
The above handler will compute the entire HTTP response and send it immediately. Alternatively, your HTTP handler may ask WebSocket++ core to defer sending the response until a later time. This gives your program the chance to perform longer calculations or load data from slower files/databases without blocking other network operations. The example below demonstrates the usage of this style using an asynchronous operation and a lambda callback. You could also use a worker thread to process the request and send the response.
Usage Notes / Warnings
If you intend to serve any high volume or HTTP resources or need modern HTTP features it is strongly recommended that you serve this traffic from dedicated HTTP server software like Apache or Ngnix.