 
   setParticipantStates: (participantStates) ->
     @participants = participantStates.map (state) -> new Participant(state)
+
+  getClientIdToSiteIdMap: -> @doc.get('collaborationState.clientIdToSiteId')
 
   subscribe: (name) ->
     token = keytar.getPassword('github.com', 'github')

      collaborationState:
        guest: {description: '', candidate: '', ready: false}
        host: {description: '', candidate: ''}
        repositoryState:
          url: project.getRepo().getConfigValue('remote.origin.url')
          branch: project.getRepo().getShortHead()

      @mediaConnection = @createMediaConnection()
      @mediaConnection.start()

      @getClientIdToSiteIdMap().set(@clientId, @site.id)

      @connectDocument()
      @channel.one 'channel:subscribed', (participantStates) =>
        @setParticipantStates(participantStates)
        @listening = true
        @trigger 'started', @getParticipants()

      @on 'participant-entered', (participant) =>
        # inject siteId; TODO: should be moved to somewhere less sketch
        guestSiteId = @nextGuestSiteId++
        clientIdToSiteId = @getClientIdToSiteIdMap()
        clientIdToSiteId.set(participant.clientId, guestSiteId)

        @snapshotRepository (repoSnapshot) =>
          welcomePackage =
            siteId: guestSiteId
            doc: @doc.serialize()
            repoSnapshot: repoSnapshot
          @channel.send 'welcome', welcomePackage
