NakamaGrpcClient constructor

NakamaGrpcClient({
  1. required String host,
  2. int port = 7349,
  3. required bool ssl,
  4. required String serverKey,
})

Implementation

NakamaGrpcClient({
  required this.host,
  this.port = 7349,
  required this.ssl,
  required String serverKey,
}) {
  this.serverKey = 'Basic ${base64Encode('$serverKey:'.codeUnits)}';

  _log.info('Connecting to $host:$port');
  _channel = ClientChannel(
    host,
    port: port,
    options: ChannelOptions(
      credentials: ssl == true
          ? const ChannelCredentials.secure()
          : const ChannelCredentials.insecure(),
    ),
  );

  _client = NakamaClient(
    _channel,
    options: CallOptions(metadata: {'authorization': this.serverKey}),
  );
}