changeset 1895:a609c419d7b6

support rdfdb 0.19.0 telling us our connection id in its logs Ignore-this: dafead665ead86a7c00afbc051222f8f
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 30 May 2019 08:31:58 +0000
parents b697752b35f9
children f65ed3b2231b
files light9/web/rdfdbclient.coffee
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/rdfdbclient.coffee	Thu May 30 08:31:29 2019 +0000
+++ b/light9/web/rdfdbclient.coffee	Thu May 30 08:31:58 2019 +0000
@@ -28,9 +28,8 @@
     cb(JSON.stringify(out))
   )
 
-parseJsonPatch = (jsonPatch, cb) ->
+parseJsonPatch = (input, cb) ->
   # note response cb doesn't have an error arg.
-  input = JSON.parse(jsonPatch)
   patch = {delQuads: [], addQuads: []}
 
   parseAdds = (cb) =>
@@ -58,14 +57,14 @@
     @_lastPingMs = -1
     @_patchesReceived = 0
     @_patchesSent = 0
-
+    @_connectionId = '??'
     @_reconnectionTimeout = null
     @_newConnection()
 
   _updateStatus: ->
     ws = (if not @ws? then 'no' else switch @ws.readyState
       when @ws.CONNECTING then 'connecting'
-      when @ws.OPEN then 'open'
+      when @ws.OPEN then "open as #{@_connectionId}"
       when @ws.CLOSING then 'closing'
       when @ws.CLOSED then 'close'
       )
@@ -121,8 +120,13 @@
       @_lastPingMs = Date.now() + @_lastPingMs
       @_updateStatus()
       return
-    parseJsonPatch(msg, @applyPatch.bind(@))
-    @_patchesReceived++
+      
+    input = JSON.parse(msg)
+    if input.connectedAs
+      @_connectionId = input.connectedAs
+    else
+      parseJsonPatch(input, @applyPatch.bind(@))
+      @_patchesReceived++
     @_updateStatus()
 
   _continueSending: ->