diff --git a/light9/web/graph.coffee b/light9/web/graph.coffee --- a/light9/web/graph.coffee +++ b/light9/web/graph.coffee @@ -146,7 +146,7 @@ class window.SyncedGraph # 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 @@ class window.SyncedGraph log('graph: clearGraphOnNewConnection') @clearGraph() log('graph: clearGraphOnNewConnection done') + @clearCb() if @clearCb? _addPrefixes: (prefixes) -> for k in (prefixes or {}) @@ -218,6 +219,9 @@ class window.SyncedGraph 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 @@ class window.SyncedGraph 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) -> diff --git a/light9/web/light9-music.coffee b/light9/web/light9-music.coffee --- a/light9/web/light9-music.coffee +++ b/light9/web/light9-music.coffee @@ -1,5 +1,4 @@ log = debug('music') -debug.enable('music') # port of light9/curvecalc/musicaccess.py coffeeElementSetup(class Music extends Polymer.Element diff --git a/light9/web/live/live.coffee b/light9/web/live/live.coffee --- a/light9/web/live/live.coffee +++ b/light9/web/live/live.coffee @@ -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 @@ coffeeElementSetup(class Light9LiveContr 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 diff --git a/light9/web/rdfdb-synced-graph.html b/light9/web/rdfdb-synced-graph.html --- a/light9/web/rdfdb-synced-graph.html +++ b/light9/web/rdfdb-synced-graph.html @@ -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; } } diff --git a/light9/web/rdfdbclient.coffee b/light9/web/rdfdbclient.coffee --- a/light9/web/rdfdbclient.coffee +++ b/light9/web/rdfdbclient.coffee @@ -51,6 +51,12 @@ parseJsonPatch = (input, cb) -> 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 @@ class window.RdfDbClient @ws = new WebSocket(fullUrl) @ws.onopen = => - log('rdfdbclient: connected to', fullUrl) + log('rdfdbclient: new connection to', fullUrl) @_updateStatus() @clearGraphOnNewConnection() @_pingLoop()