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