Peer constructor
Peer({
- String? id,
- PeerOptions? options,
Implementation
Peer({String? id, PeerOptions? options})
: _options = options ?? PeerOptions(),
_api = API(options ?? PeerOptions()),
_socket = Socket(
options?.secure ?? util.isSecure(),
options?.host ?? util.CLOUD_HOST,
options?.port ?? util.CLOUD_PORT,
options?.path ?? '/',
options?.key ?? DEFAULT_KEY,
clientType: options?.clientType ?? "websocket",
pingInterval: options?.pingInterval ?? 5000,
) {
_serializers = {..._serializers, ..._options.serializers};
_options.host = _options.host == '/' ? 'localhost' : _options.host;
_options.path = _options.path?.startsWith('/') ?? false ? _options.path : '/${_options.path}';
_options.path = _options.path?.endsWith('/') ?? false ? _options.path : '${_options.path}/';
logger.logLevel = _options.debug ?? LogLevel.Disabled;
if (_options.logFunction != null) {
logger.setLogFunction(_options.logFunction!);
}
}