Use Sync3 instead of Sync in SessionContainer

This makes H use Sync3! Hard-code endpoint to localhost:8008 for now.
This commit is contained in:
Kegan Dougal 2021-11-30 15:09:46 +00:00
parent 0f2d1ae2cc
commit b2eaf0f155
4 changed files with 14 additions and 5 deletions

View file

@ -5,7 +5,8 @@
module.exports = { module.exports = {
mount: { mount: {
// More specific paths before less specific paths (if they overlap) // More specific paths before less specific paths (if they overlap)
"src": "/", "src/platform/web/docroot": "/",
"src": "/src",
"lib": {url: "/lib", static: true }, "lib": {url: "/lib", static: true },
"assets": "/assets", "assets": "/assets",
/* ... */ /* ... */

View file

@ -24,7 +24,8 @@ import {Reconnector, ConnectionStatus} from "./net/Reconnector.js";
import {ExponentialRetryDelay} from "./net/ExponentialRetryDelay.js"; import {ExponentialRetryDelay} from "./net/ExponentialRetryDelay.js";
import {MediaRepository} from "./net/MediaRepository.js"; import {MediaRepository} from "./net/MediaRepository.js";
import {RequestScheduler} from "./net/RequestScheduler.js"; import {RequestScheduler} from "./net/RequestScheduler.js";
import {Sync, SyncStatus} from "./Sync.js"; // import {Sync, SyncStatus} from "./Sync.js";
import {Sync3, SyncStatus} from "./Sync3";
import {Session} from "./Session.js"; import {Session} from "./Session.js";
import {PasswordLoginMethod} from "./login/PasswordLoginMethod.js"; import {PasswordLoginMethod} from "./login/PasswordLoginMethod.js";
import {TokenLoginMethod} from "./login/TokenLoginMethod.js"; import {TokenLoginMethod} from "./login/TokenLoginMethod.js";
@ -254,7 +255,12 @@ export class SessionContainer {
await log.wrap("createIdentity", log => this._session.createIdentity(log)); await log.wrap("createIdentity", log => this._session.createIdentity(log));
} }
this._sync = new Sync({hsApi: this._requestScheduler.hsApi, storage: this._storage, session: this._session, logger: this._platform.logger}); this._sync = new Sync3(
this._requestScheduler.hsApi,
this._session,
this._storage,
this._platform.logger,
);
// notify sync and session when back online // notify sync and session when back online
this._reconnectSubscription = this._reconnector.connectionStatus.subscribe(state => { this._reconnectSubscription = this._reconnector.connectionStatus.subscribe(state => {
if (state === ConnectionStatus.Online) { if (state === ConnectionStatus.Online) {

View file

@ -236,7 +236,7 @@ export class Sync3 {
backoffCounter = 5; backoffCounter = 5;
} }
const secs = Math.pow(2, backoffCounter); const secs = Math.pow(2, backoffCounter);
console.log(`v3 /sync failed, backing off for ${secs}s`) console.log(`v3 /sync failed, backing off for ${secs}s, err=`, err);
await sleep(secs * 1000); await sleep(secs * 1000);
} }
} }

View file

@ -111,7 +111,9 @@ export class HomeServerApi {
} }
sync3(body, pos, timeout, options = null) { sync3(body, pos, timeout, options = null) {
return this._authedRequest("POST", this._url("/sync", "/_matrix/client/v3"), {timeout, pos}, body, options); // FIXME TODO
const syncURL = "http://localhost:8008/_matrix/client/v3/sync";
return this._authedRequest("POST", syncURL, {timeout, pos}, body, options);
} }
// params is from, dir and optionally to, limit, filter. // params is from, dir and optionally to, limit, filter.