)
Upgrades a HttpRequest to a WebSocket connection. If the request is not a valid WebSocket upgrade request an HTTP response with status code 500 will be returned. Otherwise the returned future will complete with the WebSocket when the upgrade pocess is complete.
If protocolSelector
is provided, protocolSelector
will be called to
select what protocol to use, if any were provided by the client.
protocolSelector
is should return either a String or a Future
completing with a String. The String must exist in the list of
protocols.
Source
/**
* Upgrades a [HttpRequest] to a [WebSocket] connection. If the
* request is not a valid WebSocket upgrade request an HTTP response
* with status code 500 will be returned. Otherwise the returned
* future will complete with the [WebSocket] when the upgrade pocess
* is complete.
*
* If [protocolSelector] is provided, [protocolSelector] will be called to
* select what protocol to use, if any were provided by the client.
* [protocolSelector] is should return either a [String] or a [Future]
* completing with a [String]. The [String] must exist in the list of
* protocols.
*/
static Future<WebSocket> upgrade(HttpRequest request,
{protocolSelector(List<String> protocols)}) {
return _WebSocketTransformerImpl._upgrade(request, protocolSelector);
}