WebSocketHandler constructor

WebSocketHandler({
  1. required void message(
    1. ServerWebSocket,
    2. JSAny
    ),
  2. void open(
    1. ServerWebSocket
    )?,
  3. void close(
    1. ServerWebSocket, [
    2. JSNumber?,
    3. JSString?
    ])?,
  4. void error(
    1. ServerWebSocket,
    2. JSAny
    )?,
})

Creates a new websocket handler.

Implementation

factory WebSocketHandler({
  required void Function(ServerWebSocket, JSAny) message,
  void Function(ServerWebSocket)? open,
  void Function(ServerWebSocket, [JSNumber?, JSString?])? close,
  void Function(ServerWebSocket, JSAny)? error,
}) {
  final inner = JSObject()..['message'] = message.toJS;

  return WebSocketHandler._(inner);
}