This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/session.js
2019-02-04 22:29:46 +00:00

28 lines
638 B
JavaScript

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;
}
load() {
// what is the PK for a session [user_id, device_id], a uuid?
}
getRoom(roomId) {
return this._rooms[roomId];
}
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);
}
}