NakamaWebsocketClient.init constructor

NakamaWebsocketClient.init({
  1. String key = 'default',
  2. required String host,
  3. int port = 7350,
  4. required bool ssl,
  5. required String token,
  6. dynamic onDone()?,
  7. dynamic onError(
    1. dynamic error
    )?,
})

Implementation

factory NakamaWebsocketClient.init({
  String key = 'default',
  required String host,
  int port = 7350,
  required bool ssl,
  required String token,
  Function()? onDone,
  Function(dynamic error)? onError,
}) {
  // Has the client already been initialized? Then return it.
  if (_clients.containsKey(key)) {
    return instanceFor(key: key);
  }

  // Create new and return instance of this.
  return _clients[key] = NakamaWebsocketClient._(
    host: host,
    port: port,
    ssl: ssl,
    token: token,
    onDone: onDone,
    onError: onError,
  );
}