 
       triggerPush = true
 
-    buffer.onDidChange (event) ->
+    buffer.onDidChange (event) =>
       return unless triggerPush
       deletion = !(event.newText is "\n") and (event.newText.length is 0)
-      pairingChannel.trigger 'client-change', {deletion: deletion, event: event}
+      @pairingChannel.trigger 'client-change', {deletion: deletion, event: event}
+
+  shareCurrentFile: (buffer)->
+    currentFile = buffer.getText()
+    @pairingChannel.trigger 'client-share-file', currentFile

      @startView = new StartView(@sessionId)
      @startPanel = atom.workspace.addModalPanel(item: @startView, visible: true)
      @startView.focus()
      @startPairing()

  inviteOverHipChat: ->


    buffer = atom.workspace.getActiveEditor().buffer

    @pusher = new Pusher @app_key,
      authTransport: 'client'
      clientAuth:
        key: @app_key
        secret: @app_secret
        user_id: "user"

    @pairingChannel = @pusher.subscribe("presence-session-#{@sessionId}")

    @pairingChannel.bind 'pusher:subscription_succeeded', (members) =>
      console.log "I'm coming!"
      @pairingChannel.trigger 'client-joined', {joined: true}

    @pairingChannel.bind 'client-joined', (data) =>
      @subscriptions.add atom.commands.add 'atom-workspace', 'pusht:share current file': => @shareCurrentFile(buffer)

    @pairingChannel.bind 'client-share-file', (file) ->
      triggerPush = false
      buffer.setText(file)
      triggerPush = true

    @pairingChannel.bind 'client-change', (data) ->

      newRange = Range.fromObject(data.event.newRange)
      oldRange = Range.fromObject(data.event.oldRange)
