 
     else
       @channel.one 'channel:subscribed', (participantStates) =>
+        console.log "subscribed to #{@id} as peer"
         @setParticipantStates(participantStates)
         @channel.one 'welcome', ({doc, siteId, repoSnapshot}) =>
           @site = new Site(siteId)

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

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


  getClientIdToSiteIdMap: -> @doc.get('collaborationState.clientIdToSiteId')

  subscribe: (name) ->
    console.log "subscribing to #{name}"
    token = keytar.getPassword('github.com', 'github')
    channel = new WsChannel({name, @host, @port, @secure, token})
    {@clientId} = channel
