Changeset - cdfd2901918a
[Not reviewed]
default
0 4 0
drewp@bigasterisk.com - 20 months ago 2023-06-01 21:21:20
drewp@bigasterisk.com
logging
4 files changed with 9 insertions and 6 deletions:
0 comments (0 inline, 0 general)
light9/web/RdfDbChannel.ts
Show inline comments
 
@@ -54,15 +54,15 @@ export class RdfDbChannel {
 
    this.ws.send(body);
 
    this.messagesSent++;
 
    this.updateStatus();
 
    return true;
 
  }
 

	
 
  disconnect() {
 
  disconnect(why:string) {
 
    // will be followed by an autoconnect
 
    log("disconnect requested");
 
    log("disconnect requested:", why);
 
    if (this.ws !== undefined) {
 
      const closeHandler = this.ws.onclose?.bind(this.ws);
 
      if (!closeHandler) {
 
        throw new Error();
 
      }
 
      closeHandler(new CloseEvent("forced"));
 
@@ -120,13 +120,13 @@ export class RdfDbChannel {
 
    this.messagesReceived++;
 
    this.updateStatus();
 
  }
 

	
 
  private onWsError(e: Event) {
 
    log("ws error", e);
 
    this.disconnect();
 
    this.disconnect("ws error");
 
    this.updateStatus();
 
  }
 

	
 
  private onWsClose(ev: CloseEvent) {
 
    log("ws close");
 
    this.updateStatus();
light9/web/SyncedGraph.ts
Show inline comments
 
@@ -35,13 +35,13 @@ export class SyncedGraph {
 
  ) {
 
    this.prefixFuncs = this.rebuildPrefixFuncs(prefixes);
 
    this.graph = new N3.Store();
 
    this.autoDeps = new AutoDependencies(this);
 
    this.autoDeps.graphError.subscribe((e) => {
 
      log("graph learned of error - reconnecting", e);
 
      this.client.disconnect();
 
      this.client.disconnect("graph error");
 
    });
 
    this.clearGraph();
 

	
 
    this.client = new RdfDbClient(patchSenderUrl, this._clearGraphOnNewConnection.bind(this), this._applyPatch.bind(this), this.setStatus);
 
  }
 

	
light9/web/patch.ts
Show inline comments
 
@@ -74,12 +74,15 @@ export class Patch {
 

	
 
  summary(): string {
 
    return "-" + this.dels.size + " +" + this.adds.size;
 
  }
 

	
 
  dump(): string {
 
    if (this.dels.size + this.adds.size > 20) {
 
      return this.summary();
 
    }
 
    const lines: string[] = [];
 
    const s = (term: N3.Term): string => {
 
      if (term.termType == "Literal") return term.value;
 
      if (term.termType == "NamedNode")
 
        return term.value
 
          .replace("http://light9.bigasterisk.com/effect/", "effect:")
light9/web/rdfdbclient.ts
Show inline comments
 
@@ -41,14 +41,14 @@ export class RdfDbClient {
 
  sendPatch(patch: Patch) {
 
    log("queue patch to server ", patch.summary());
 
    this._patchesToSend.push(patch);
 
    this._continueSending();
 
  }
 

	
 
  disconnect() {
 
    this.channel.disconnect();
 
  disconnect(why:string) {
 
    this.channel.disconnect(why);
 
  }
 

	
 
  async _continueSending() {
 
    // we could call this less often and coalesce patches together to optimize
 
    // the dragging cases. See rdfdb 'compactPatches' and 'processInbox'.
 
    while (this._patchesToSend.length) {
0 comments (0 inline, 0 general)