   initialize: (options) ->
     @in_flight = new zc.InFlight(app: @app)
     @model = new Backbone.Model(state: 'closed')
-    @queue = []
     @app.vent.on('start', _.bind(@connect, @))
     @app.reqres.setHandler 'send-packet', _.bind(@send, @)
     @app.commands.setHandler 'reconnect', =>


  on_open: ->
    @model.set(state: 'open')
    current_queue = @queue
    @queue = []
    @ws_send(
      type: 'authenticate'
      identity: @app.request('identity').get('fingerprint')
    )
    current_queue.slice().forEach (msg) =>
      @send(msg)
    @app.vent.trigger('connect')

  on_close: ->


    @in_flight.reply(msg)

  send: (msg) ->
    promise = @in_flight.wrap(msg)
    if @ws.readyState == WebSocket.OPEN
      @ws.send(JSON.stringify(msg))
    else
      promise.reject('disconnected')
    return promise


