Changeset - e29315086f9f
[Not reviewed]
default
0 5 0
Drew Perttula - 6 years ago 2019-06-01 05:49:17
drewp@bigasterisk.com
minor touchups to live & graph, looking at why reconnects are broken
Ignore-this: fa0b69132da3b44593bf8eb056315d7e
5 files changed with 21 insertions and 7 deletions:
0 comments (0 inline, 0 general)
light9/web/graph.coffee
Show inline comments
 
@@ -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) ->
light9/web/light9-music.coffee
Show inline comments
 
log = debug('music')
 
debug.enable('music')
 

	
 
# port of light9/curvecalc/musicaccess.py
 
coffeeElementSetup(class Music extends Polymer.Element
light9/web/live/live.coffee
Show inline comments
 
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
light9/web/rdfdb-synced-graph.html
Show inline comments
 
@@ -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;
 
       }
 
   }
light9/web/rdfdbclient.coffee
Show inline comments
 
@@ -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()
0 comments (0 inline, 0 general)