useExistingSession method

Future<void> useExistingSession(
  1. SessionInfo session
)

Use an existing session

Implementation

Future<void> useExistingSession(SessionInfo session) async {
    if (_authStarted) throw 'Cannot authenticate again';
    _authStarted = true;
    sessionInfo = session;
    _authHeaders = {
        'x-user-id': session.clientId,
        'x-session-token': session.sessionToken,
        'User-Agent': clientConfig.user_agent,
    };

    serverConfig = await _fetchServerConfig();

    if (!await _validateSession(session, clientConfig)) {
        throw 'Invalid session';
    }

    wsClient = WSClient(revoltClient: this, heartbeat: 10);
    await wsClient.connect();
}