       console.log "julia-client: unrecognised message #{type}"
       console.log data
 
+  output: (data) ->
+
+  msg: (type, data, f) ->
+    return unless @isConnected()
+    if f?
+      data.callback = @id = @id+1
+      @callbacks[@id] = f
+      @loading.working()
+    @output [type, data]
+
+  handle: (type, f) ->
+    @handlers[type] = f
+
+  # Connecting & Booting
+
+  emitter: new Emitter()
+
+  onConnected: (cb) -> @emitter.on('connected', cb)
+  onDisconnected: (cb) -> @emitter.on('disconnected', cb)
+
   isConnected: -> false
 
   booting: ->

    if @isBooting
      @isBooting = false
      @loading.done()

  connectedError: ->
    if @isConnected()


module.exports =

  # Messaging

  handlers: {}
  callbacks: {}
