private void ValidateAndInitializeSessionIds() { if (Destination == Source) { throw new InvalidOperationException("Client cannot accept invitation (or invite) himself"); } if (!Source.GotInviteFrom(Destination.Id)) { throw new InvalidOperationException( $"Client have not received an invitation from a client with ID {Destination.Id}"); } DestinationSessionId = SessionsRepository.GetSessionId(Destination); var sourceSessionId = SessionsRepository.GetSessionId(Source); if (DestinationSessionId == sourceSessionId) { throw new InvalidOperationException($"Client {Destination.Id} is already in your session"); } if (SessionsRepository.IsSessionFull(sourceSessionId)) { throw new InvalidOperationException("Client's session is full"); } if (SessionsRepository.IsSessionFull(DestinationSessionId)) { throw new InvalidOperationException("Inviter session is full"); } SessionsRepository.UpdateClientSessionId(Source, DestinationSessionId); }
private void ValidateAndInitializeSessionIds() { if (Destination == Source) { throw new InvalidOperationException("Client cannot invite himself to the session"); } if (SessionsRepository.IsSessionFull(_sourceSessionId)) { throw new InvalidOperationException("Session is full"); } if (SessionsRepository.IsSessionFull(DestinationSessionId)) { throw new InvalidOperationException($"Client's {Destination.Id} session is full"); } if (Destination.GotInviteFrom(Source.Id)) { throw new InvalidOperationException( $"Already invited client with ID: {Destination.Id}"); } DestinationSessionId = SessionsRepository.GetSessionId(Destination); if (DestinationSessionId == _sourceSessionId) { throw new InvalidOperationException("Invited client is already in this session"); } }
protected override void ValidateAndInitializeCommandArguments() { Destination = Source; DestinationSessionId = SessionsRepository.GetSessionId(Destination); // source is only client in session if (!SessionsRepository.IsSessionFull(DestinationSessionId)) { throw new InvalidOperationException( "Closing communication session and moving to new one is possible only if other client is in your session"); } SessionsRepository.UpdateClientSessionId(Destination, Guid.NewGuid()); DestinationSessionId = SessionsRepository.GetSessionId(Destination); }
private void ValidateAndInitializeDestination() { if (!SessionsRepository.IsSessionFull(_sourceSessionId)) { throw new InvalidOperationException("No other client in client's session"); } try { Destination = SessionsRepository.GetSecondClientFromSession(_sourceSessionId, Source); } catch (InvalidOperationException) { throw new InvalidOperationException("Error, try again"); } DestinationSessionId = _sourceSessionId; }