LayrzProtocolSocket constructor

LayrzProtocolSocket({
  1. required String ident,
  2. String password = '',
  3. required String server,
  4. LayrzProtocolVersion version = LayrzProtocolVersion.v2,
  5. BlackboxStoreCallback? onBlackboxStore,
  6. BlackboxFetchCallback? onBlackboxFetch,
})

Implementation

LayrzProtocolSocket({
  required this.ident,
  this.password = '',
  required this.server,
  this.version = LayrzProtocolVersion.v2,
  this.onBlackboxStore,
  this.onBlackboxFetch,
}) : assert(ident.isNotEmpty) {
  if (server.contains(':')) {
    _host = server.split(':')[0];
    _port = int.tryParse(server.split(':')[1]) ?? 0;
    if (_port <= 0) throw ArgumentError('The port should be a number and greater than 0');
  } else {
    throw ArgumentError('The server should contain the port');
  }
}