mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Open new window when joining collaboration session
This commit is contained in:
committed by
Nathan Sobo
parent
b08f320ed5
commit
b5b408d134
@@ -295,8 +295,8 @@ class Pane extends View
|
||||
@viewForItem(@activeItem)
|
||||
|
||||
serialize: ->
|
||||
@state.get('items').set(index, item.serialize()) for item, index in @items
|
||||
@state.set
|
||||
items: @items.map (item) -> item.serialize()
|
||||
focused: @is(':has(:focus)')
|
||||
activeItemUri: @activeItem.getUri?()
|
||||
@state
|
||||
|
||||
36
src/packages/collaboration/lib/bootstrap.coffee
Normal file
36
src/packages/collaboration/lib/bootstrap.coffee
Normal file
@@ -0,0 +1,36 @@
|
||||
require 'atom'
|
||||
require 'window'
|
||||
_ = require 'underscore'
|
||||
|
||||
window.setDimensions(x: 0, y: 0, width: 800, height: 800)
|
||||
atom.show()
|
||||
|
||||
Peer = require './peer'
|
||||
Guid = require 'guid'
|
||||
{createSite, Document} = require 'telepath'
|
||||
|
||||
peerJsSettings =
|
||||
host: 'ec2-54-218-51-127.us-west-2.compute.amazonaws.com'
|
||||
port: 8080
|
||||
|
||||
wireDocumentEvents = (connection, sharedDocument) ->
|
||||
sharedDocument.outputEvents.on 'changed', (event) ->
|
||||
console.log 'sending event', event
|
||||
connection.send(event)
|
||||
|
||||
connection.on 'data', (event) ->
|
||||
console.log 'receiving event', _.clone(event.targetPath)
|
||||
sharedDocument.handleInputEvent(event)
|
||||
|
||||
siteId = Guid.create().toString()
|
||||
peer = new Peer(siteId, peerJsSettings)
|
||||
{sessionId} = atom.getLoadSettings()
|
||||
connection = peer.connect(sessionId, reliable: true)
|
||||
connection.on 'open', ->
|
||||
console.log 'connection opened'
|
||||
connection.once 'data', (data) ->
|
||||
console.log 'received data', data
|
||||
atom.windowState = Document.deserialize(createSite(siteId), data)
|
||||
wireDocumentEvents(connection, atom.windowState)
|
||||
window.setUpEnvironment('editor')
|
||||
window.startEditorWindow()
|
||||
@@ -47,11 +47,16 @@ module.exports =
|
||||
sessionId = null
|
||||
|
||||
rootView.command 'collaboration:copy-session-id', ->
|
||||
pasteboart.write(sessionId) if sessionId
|
||||
pasteboard.write(sessionId) if sessionId
|
||||
|
||||
rootView.command 'collaboration:start-session', ->
|
||||
if sessionId = startSession()
|
||||
pasteboard.write(sessionId)
|
||||
|
||||
rootView.command 'collaboration:join-session', ->
|
||||
new Prompt(joinSession)
|
||||
new Prompt (id) ->
|
||||
windowSettings =
|
||||
bootstrapScript: require.resolve('collaboration/lib/bootstrap')
|
||||
resourcePath: window.resourcePath
|
||||
sessionId: id
|
||||
atom.openWindow(windowSettings)
|
||||
|
||||
Reference in New Issue
Block a user