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

28 lines
638 B
JavaScript
Raw Normal View History

export default class Session {
// sessionData has device_id, user_id, home_server (not access_token, that is for network)
constructor(sessionData, storage) {
2018-12-21 19:05:24 +05:30
this._sessionData = sessionData;
this._storage = storage;
this._rooms = {};
this._syncToken = null;
2018-12-21 19:05:24 +05:30
}
load() {
2018-12-21 19:05:24 +05:30
// 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;
}
2018-12-21 19:05:24 +05:30
applySync(syncToken, accountData, txn) {
this._syncToken = syncToken;
txn.session.setSyncToken(syncToken);
2018-12-21 19:05:24 +05:30
}
}