NakamaGrpcClient.init constructor
NakamaGrpcClient.init({})
Either inits and returns a new instance of NakamaGrpcClient or returns a already initialized one.
Implementation
factory NakamaGrpcClient.init({
String? host,
String? serverKey,
String key = _kDefaultAppKey,
int port = 7349,
bool ssl = false,
}) {
if (_clients.containsKey(key)) {
return _clients[key]!;
}
// Not yet initialized -> check if we've got all parameters to do so
if (host == null || serverKey == null) {
throw Exception(
'Not yet initialized, need parameters [host] and [serverKey] to initialize.',
);
}
// Create a new instance of this with given parameters.
return _clients[key] = NakamaGrpcClient(
host: host,
port: port,
serverKey: serverKey,
ssl: ssl,
);
}