changeset 1905:e29315086f9f

minor touchups to live & graph, looking at why reconnects are broken Ignore-this: fa0b69132da3b44593bf8eb056315d7e
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 01 Jun 2019 05:49:17 +0000
parents 5f31e02fbf70
children d4038ddf6cc9
files light9/web/graph.coffee light9/web/light9-music.coffee light9/web/live/live.coffee light9/web/rdfdb-synced-graph.html light9/web/rdfdbclient.coffee
diffstat 5 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/graph.coffee	Sat Jun 01 02:26:05 2019 +0000
+++ b/light9/web/graph.coffee	Sat Jun 01 05:49:17 2019 +0000
@@ -146,7 +146,7 @@
   # Note that _applyPatch is the only method to write to the graph, so
   # it can fire subscriptions.
 
-  constructor: (@patchSenderUrl, @prefixes, @setStatus) ->
+  constructor: (@patchSenderUrl, @prefixes, @setStatus, @clearCb) ->
     # patchSenderUrl is the /syncedGraph path of an rdfdb server.
     # prefixes can be used in Uri(curie) calls.
     @_autoDeps = new AutoDependencies() # replaces GraphWatchers
@@ -173,6 +173,7 @@
     log('graph: clearGraphOnNewConnection')
     @clearGraph()
     log('graph: clearGraphOnNewConnection done')
+    @clearCb() if @clearCb?
       
   _addPrefixes: (prefixes) ->
     for k in (prefixes or {})
@@ -218,6 +219,9 @@
 
   applyAndSendPatch: (patch) ->
     console.time('applyAndSendPatch')
+    if not @_client
+      log('not connected-- dropping patch')
+      return
     if !Array.isArray(patch.addQuads) || !Array.isArray(patch.delQuads)
       console.timeEnd('applyAndSendPatch')
       log('corrupt patch')
@@ -368,7 +372,7 @@
 
   contains: (s, p, o) ->
     @_autoDeps.askedFor(s, p, o, null)
-    log('contains calling getQuads when graph has ', 
+    log('contains calling getQuads when graph has ', @graph.size)
     return @graph.getQuads(s, p, o).length > 0
 
   nextNumberedResources: (base, howMany) ->
--- a/light9/web/light9-music.coffee	Sat Jun 01 02:26:05 2019 +0000
+++ b/light9/web/light9-music.coffee	Sat Jun 01 05:49:17 2019 +0000
@@ -1,5 +1,4 @@
 log = debug('music')
-debug.enable('music')
 
 # port of light9/curvecalc/musicaccess.py
 coffeeElementSetup(class Music extends Polymer.Element
--- a/light9/web/live/live.coffee	Sat Jun 01 02:26:05 2019 +0000
+++ b/light9/web/live/live.coffee	Sat Jun 01 05:49:17 2019 +0000
@@ -1,5 +1,4 @@
 log = debug('live')
-debug.enable('live')
 
 # Like element.set(path, newArray), but minimizes splices.
 # Dotted paths don't work yet.
@@ -471,6 +470,7 @@
       for dev in @graph.sortedUris(@graph.subjects(U('rdf:type'), dc))
         newDevs.push({uri: dev})
 
+    log("controls update now has #{newDevs.length} devices")
     syncArray(@, 'devices', newDevs, (a, b) -> a.uri.value == b.uri.value)
 
     return
--- a/light9/web/rdfdb-synced-graph.html	Sat Jun 01 02:26:05 2019 +0000
+++ b/light9/web/rdfdb-synced-graph.html	Sat Jun 01 05:49:17 2019 +0000
@@ -29,7 +29,11 @@
                testGraph: {type: Boolean},
            }
        }
-       
+
+       onClear() {
+           console.log('reset')
+       }
+     
        connectedCallback() {
            super.connectedCallback();
            this.graph = new SyncedGraph(
@@ -41,7 +45,8 @@
                    'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',
                    'xsd': 'http://www.w3.org/2001/XMLSchema#',
                },
-               function(s) { this.status = s; }.bind(this));
+             function(s) { this.status = s; }.bind(this),
+             this.onClear.bind(this));
            window.graph = this.graph;
        }
    }
--- a/light9/web/rdfdbclient.coffee	Sat Jun 01 02:26:05 2019 +0000
+++ b/light9/web/rdfdbclient.coffee	Sat Jun 01 05:49:17 2019 +0000
@@ -51,6 +51,12 @@
 
 class window.RdfDbClient
   # Send and receive patches from rdfdb
+  #
+  # What this should do, and does not yet, is keep the graph
+  # 'coasting' over a reconnect, applying only the diffs from the old
+  # contents to the new ones once they're in. Then, remove all the
+  # clearGraph stuff in graph.coffee that doesn't even work right.
+  # 
   constructor: (@patchSenderUrl, @clearGraphOnNewConnection, @applyPatch,
                 @setStatus) ->
     @_patchesToSend = []
@@ -89,7 +95,7 @@
     @ws = new WebSocket(fullUrl)
 
     @ws.onopen = =>
-      log('rdfdbclient: connected to', fullUrl)
+      log('rdfdbclient: new connection to', fullUrl)
       @_updateStatus()
       @clearGraphOnNewConnection()
       @_pingLoop()