negotiate static method

int negotiate(
  1. List<int> clientVersions
)

The highest version from clientVersions this library supports.

Implementation

static int negotiate(List<int> clientVersions) {
  final overlap = clientVersions
      .where(supportedWireVersions.contains)
      .toList();
  if (overlap.isEmpty) {
    throw WireVersionError(
      'no protocol version overlap: client offers $clientVersions, '
      'server supports ${supportedWireVersions.toList()..sort()}',
    );
  }
  overlap.sort();
  return overlap.last;
}