init method

Future<void> init(
  1. ChessnutCommunicationClient client
)

Implementation

Future<void> init(ChessnutCommunicationClient client) async {
  _client = client;
  _client.receiveStream.listen(_handleInputStream);
  _inputStreamController = StreamController<ChessnutMessage>();
  _boardUpdateStreamController = StreamController<Map<String, String>>();
  _inputStream = _inputStreamController.stream.asBroadcastStream() as Stream<ChessnutMessage>?;
  _boardUpdateStream = _boardUpdateStreamController.stream.asBroadcastStream() as Stream<Map<String, String>>?;

  getInputStream()!.map(_createBoardMap).listen(_newBoardState);

  Future<void> ack = getAckFuture();
  _send(Uint8List.fromList([0x21, 0x01, 0x00]));
  await ack;
}