   _.extend @prototype, require('event-emitter')
 
   constructor: ({@site, @id, @host, @port, @secure}) ->
+    @nextOutgoingEventId = 1
+    @lastEventIdsBySite = {}
+
     @secure ?= config.get('collaboration.secure') ? true
     @host ?= config.get('collaboration.host') ? 'fallout.in'
     @participants = []

    {@clientId} = channel
    channel

  connectDocument:  ->
    @doc.on 'replicate-change', (event) =>
      @channel.send('document-changed', event)

    @channel.on 'document-changed', (event) =>
      @doc.applyRemoteChange(event)

  snapshotRepository: (callback) ->

  start: ->
    @channel = @subscribe(@id)

    @channel.on 'channel:closed', =>
      @listening = false
      @trigger 'stopped'

