remove listening event, add logic to started and stopped events

This commit is contained in:
Ben Ogle
2013-07-25 17:20:50 -07:00
parent b4ee425711
commit b73f020555
2 changed files with 7 additions and 6 deletions

View File

@@ -12,15 +12,16 @@ class HostStatusBar extends View
if @session.isListening()
@session.stop()
else
@status.addClass('running') # for immediate feedback to user
@session.start()
@session.on 'listening started stopped participant-entered participant-exited', @update
@session.on 'started stopped participant-entered participant-exited', @update
@update()
update: =>
if @session.isListening()
@status.addClass('running')
@connections.show().text(@session.participants.length)
@connections.show().text(@session.getOtherParticipants().length)
else
@status.removeClass('running')
@connections.hide()

View File

@@ -32,7 +32,9 @@ class Session
start: ->
@channel = @subscribe(@id)
@channel.on 'channel:closed', => @trigger 'stopped'
@channel.on 'channel:closed', =>
@listening = false
@trigger 'stopped'
@channel.on 'channel:participant-entered', (participant) =>
@participants.push(participant)
@@ -50,6 +52,7 @@ class Session
@connectDocument()
@channel.one 'channel:subscribed', (@participants) =>
@listening = true
@trigger 'started', @getParticipants()
@on 'participant-entered', =>
@@ -60,9 +63,6 @@ class Session
repoSnapshot: repoSnapshot
@channel.send 'welcome', welcomePackage
@listening = true
@trigger 'listening'
else
@channel.one 'channel:subscribed', (@participants) =>
@channel.one 'welcome', ({doc, siteId, repoSnapshot}) =>