vector-im-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 14:35:24 +01:00
this._sessionData = sessionData;
this._storage = storage;
this._rooms = {};
this._syncToken = null;
2018-12-21 14:35:24 +01:00
}
load() {
2018-12-21 14:35:24 +01:00
// 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 14:35:24 +01:00
applySync(syncToken, accountData, txn) {
this._syncToken = syncToken;
txn.session.setSyncToken(syncToken);
2018-12-21 14:35:24 +01:00
}
}