performHandshake static method
Perform protocol handshake
Client initiates handshake, server responds with acknowledgment. Returns true if handshake successful, false otherwise.
Implementation
static Future<bool> performHandshake(
core_p2p_stream.P2PStream stream, {
required bool isClient,
Duration timeout = defaultTimeout,
String context = 'unknown',
}) async {
try {
if (isClient) {
return await _performClientHandshake(stream, timeout: timeout, context: context);
} else {
return await _performServerHandshake(stream, timeout: timeout, context: context);
}
} catch (e, stackTrace) {
_logger.severe('[$context] Handshake failed: $e', e, stackTrace);
return false;
}
}