mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Include participants data w/ HostSession 'started' event
This commit is contained in:
@@ -40,8 +40,8 @@ class HostSession extends Session
|
||||
|
||||
@doc = @createDocument()
|
||||
channel = @subscribe(@id)
|
||||
channel.on 'channel:opened', =>
|
||||
@trigger 'started'
|
||||
channel.on 'channel:subscribed', (participants) =>
|
||||
@trigger 'started', participants
|
||||
@connectDocument(@doc, channel)
|
||||
|
||||
channel.on 'channel:participant-entered', =>
|
||||
|
||||
@@ -12,10 +12,9 @@ class WsChannel
|
||||
@socket = new WebSocket("ws://localhost:8080?token=#{token}")
|
||||
@socket.onopen = =>
|
||||
@rawSend 'subscribe', @name, @clientId
|
||||
@trigger 'channel:opened'
|
||||
|
||||
@socket.onmessage = (message) =>
|
||||
[operation, data] = JSON.parse(message.data)
|
||||
data = JSON.parse(message.data)
|
||||
@trigger(data...)
|
||||
|
||||
send: (data...) ->
|
||||
|
||||
@@ -8,14 +8,24 @@ HostSession = require '../lib/host-session'
|
||||
|
||||
describe "Collaboration", ->
|
||||
describe "when a host and a guest join a channel", ->
|
||||
[server, hostSession, guestSession, repositoryMirrored] = []
|
||||
[server, hostSession, guestSession, repositoryMirrored, token, userDataByToken] = []
|
||||
|
||||
beforeEach ->
|
||||
jasmine.unspy(window, 'setTimeout')
|
||||
spyOn(keytar, 'getPassword')
|
||||
spyOn(keytar, 'getPassword').andCallFake -> token
|
||||
token = 'hubot-token'
|
||||
userDataByToken =
|
||||
'hubot-token':
|
||||
login: 'hubot'
|
||||
|
||||
server = new Server()
|
||||
spyOn(server, 'verifyClient').andCallFake (info, verify) -> verify(true)
|
||||
spyOn(server, 'log')
|
||||
spyOn(server, 'error')
|
||||
spyOn(server, 'authenticate').andCallFake (token, callback) ->
|
||||
if userData = userDataByToken[token]
|
||||
callback(null, userData)
|
||||
else
|
||||
callback("Invalid token")
|
||||
|
||||
waitsFor "server to start", (started) ->
|
||||
server.once 'started', started
|
||||
@@ -64,3 +74,15 @@ describe "Collaboration", ->
|
||||
|
||||
runs ->
|
||||
expect(repositoryMirrored).toBe true
|
||||
|
||||
it "reports on the participants of the channel", ->
|
||||
hostSession.start()
|
||||
|
||||
waitsFor "host session to start", (started) ->
|
||||
participants = null
|
||||
hostSession.one 'started', (participantsArg) ->
|
||||
participants = participantsArg
|
||||
started()
|
||||
|
||||
runs ->
|
||||
expect(participants).toEqual [login: 'hubot', clientId: hostSession.clientId]
|
||||
|
||||
Reference in New Issue
Block a user