diff --git a/src/session.js b/src/session.js index 9ae9b98c..ccd0b998 100644 --- a/src/session.js +++ b/src/session.js @@ -1,34 +1,28 @@ -class Session { - // sessionData has device_id and access_token - constructor(sessionData) { +export default class Session { + // sessionData has device_id, user_id, home_server (not access_token, that is for network) + constructor(sessionData, storage) { this._sessionData = sessionData; + this._storage = storage; + this._rooms = {}; + this._syncToken = null; } - loadFromStorage() { + load() { // what is the PK for a session [user_id, device_id], a uuid? } - start() { - if (!this._syncToken) { - do initial sync - } - do incremental sync - } - - stop() { - if (this._initialSync) { - this._initialSync.abort(); - } - if (this._incrementalSync) { - this._incrementalSync.stop(); - } - } - getRoom(roomId) { return this._rooms[roomId]; } - applySync(newRooms, syncToken, accountData) { + createRoom(roomId) { + const room = new Room(roomId, this._storage); + this._rooms[roomId] = room; + return room; + } + applySync(syncToken, accountData, txn) { + this._syncToken = syncToken; + txn.session.setSyncToken(syncToken); } } \ No newline at end of file