description

# WebSocketTransformer constructor

WebSocketTransformer({

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

})

Create a new WebSocketTransformer.

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.

Frames with uncompressed size exceeding `maxPayloadLength` will be rejected as a protocol error. The size is unlimited by default. Default value can be configured globally by setting `dart.io.default.ws.max.payload.length` value in compilation configuration environment.

## Implementation

    factory WebSocketTransformer({
      /*String|Future<String>*/ Function(List<String> protocols)?
      protocolSelector,
      CompressionOptions compression = CompressionOptions.compressionDefault,
      int maxPayloadLength = _kDefaultWebSocketMaxPayloadLength,
    }) {
      return _WebSocketTransformerImpl(
        protocolSelector,
        compression,
        maxPayloadLength,
      );
    }