description

# upgrade static method

Future<WebSocket> upgrade(

1. HttpRequest request, {
2. dynamic protocolSelector(
   1. List<String> protocols
   )?,
3. CompressionOptions compression = CompressionOptions.compressionDefault,
4. int maxPayloadLength = _kDefaultWebSocketMaxPayloadLength,

})

Upgrades an 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 process 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.

If `compression` is provided, the WebSocket created will be configured to negotiate with the specified CompressionOptions. If none is specified then the WebSocket will be created with the default CompressionOptions. See WebSocketTransformer for `maxPayloadLength`.

## Implementation

    static Future<WebSocket> upgrade(
      HttpRequest request, {
      Function(List<String> protocols)? protocolSelector,
      CompressionOptions compression = CompressionOptions.compressionDefault,
      int maxPayloadLength = _kDefaultWebSocketMaxPayloadLength,
    }) {
      return _WebSocketTransformerImpl._upgrade(
        request,
        protocolSelector,
        compression,
        maxPayloadLength: maxPayloadLength,
      );
    }