2019-02-10 21:25:29 +01:00
|
|
|
import RoomSummary from "./summary.js";
|
|
|
|
import RoomPersister from "./persister.js";
|
2018-12-21 14:35:24 +01:00
|
|
|
|
2019-02-10 21:25:29 +01:00
|
|
|
export default class Room {
|
2019-02-04 23:30:10 +01:00
|
|
|
constructor(roomId, storage) {
|
2018-12-21 14:35:24 +01:00
|
|
|
this._roomId = roomId;
|
|
|
|
this._storage = storage;
|
2019-02-10 21:25:29 +01:00
|
|
|
this._summary = new RoomSummary(roomId);
|
|
|
|
this._persister = new RoomPersister(roomId);
|
2018-12-21 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
2019-02-10 21:25:29 +01:00
|
|
|
async applySync(roomResponse, membership, txn) {
|
|
|
|
this._summary.applySync(roomResponse, membership, txn);
|
|
|
|
this._persister.persistSync(roomResponse, txn);
|
2018-12-21 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
2019-02-10 21:25:29 +01:00
|
|
|
load(summary, txn) {
|
|
|
|
this._summary.load(summary);
|
|
|
|
return this._persister.load(txn);
|
2018-12-21 14:35:24 +01:00
|
|
|
}
|
|
|
|
}
|