receiveMessage method

Message? receiveMessage(
  1. Message msg
)

Implementation

Message? receiveMessage(Message msg) {
  if (msg is Welcome) {
    if (_state != stateHelloSent && _state != stateAuthenticateSent) {
      throw Exception("received welcome when it was not expected");
    }

    _sessionDetails = SessionDetails(msg.sessionID, _realm, msg.authID, msg.authRole);
    _state = stateJoined;
    return null;
  } else if (msg is Challenge) {
    if (_state != stateHelloSent) {
      throw Exception("received challenge when it was not expected");
    }

    final authenticate = _authenticator.authenticate(msg);
    _state = stateAuthenticateSent;
    return authenticate;
  } else if (msg is Abort) {
    throw Exception("received abort");
  } else {
    throw Exception("received unknown message");
  }
}