2019-02-04 23:29:46 +01:00
|
|
|
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;
|
2019-02-04 23:29:46 +01:00
|
|
|
this._storage = storage;
|
|
|
|
this._rooms = {};
|
|
|
|
this._syncToken = null;
|
2018-12-21 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
2019-02-04 23:29:46 +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];
|
|
|
|
}
|
|
|
|
|
2019-02-04 23:29:46 +01:00
|
|
|
createRoom(roomId) {
|
|
|
|
const room = new Room(roomId, this._storage);
|
|
|
|
this._rooms[roomId] = room;
|
|
|
|
return room;
|
|
|
|
}
|
2018-12-21 14:35:24 +01:00
|
|
|
|
2019-02-04 23:29:46 +01:00
|
|
|
applySync(syncToken, accountData, txn) {
|
|
|
|
this._syncToken = syncToken;
|
|
|
|
txn.session.setSyncToken(syncToken);
|
2018-12-21 14:35:24 +01:00
|
|
|
}
|
|
|
|
}
|