validateRead method
- @visibleForTesting
Validates if a read operation is allowed in the current state
Implementation
@visibleForTesting
void validateRead() {
switch (_state) {
case XXHandshakeState.initial:
if (_isInitiator) {
throw StateError('Initiator cannot receive first message');
}
break;
case XXHandshakeState.sentE:
if (!_isInitiator) {
throw StateError('Responder cannot receive second message');
}
break;
case XXHandshakeState.sentEES:
if (_isInitiator) {
throw StateError('Initiator cannot receive third message');
}
break;
case XXHandshakeState.complete:
throw StateError('Cannot read message in completed state');
case XXHandshakeState.error:
throw StateError('Cannot read message in error state');
}
}