Initial integration of event stream.
This doesn't do much yet but log the events I'm getting until I understand them better.
This commit is contained in:
parent
5a36e46da5
commit
dfca32eb36
|
@ -263,6 +263,10 @@ export default class Client {
|
||||||
if (!this.jclient) return;
|
if (!this.jclient) return;
|
||||||
|
|
||||||
const session = this.jclient.getSession();
|
const session = this.jclient.getSession();
|
||||||
|
// Subscribe to server-pushed events
|
||||||
|
if (session.eventSourceUrl) {
|
||||||
|
this._subscribeToEventSource(session.eventSourceUrl);
|
||||||
|
}
|
||||||
this.state.session = {
|
this.state.session = {
|
||||||
...session,
|
...session,
|
||||||
accounts: Object.fromEntries(
|
accounts: Object.fromEntries(
|
||||||
|
@ -277,4 +281,16 @@ export default class Client {
|
||||||
if (!this.state.session) return;
|
if (!this.state.session) return;
|
||||||
this._triggerChange("Session");
|
this._triggerChange("Session");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_subscribeToEventSource(url: string) {
|
||||||
|
// For typechecker
|
||||||
|
if (this.jclient === null) return;
|
||||||
|
const eventSourceUrl = url
|
||||||
|
.replace("{types}", "*")
|
||||||
|
.replace("{closeafter}", "no")
|
||||||
|
.replace("{ping}", "60");
|
||||||
|
this.jclient.subscribeToEvents(eventSourceUrl, (e) => {
|
||||||
|
console.log("Got an event!", e);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d33318d3e1f7e838d9e9b828f233b98f6b21d88f
|
Subproject commit 2ef5f5b7fa0a22a499bd32831ac24622f17e10e6
|
Loading…
Reference in New Issue