Skip to content

Sending sync ipc calls isn't working #5

Closed

Description

@probablycorey

On the atom-shell branch in Atom I'm trying to recreate the functionality of atom.getWindowState using ipc, but it is not working.

On the renderer side I use this code to retrieve data from the browser process:

dataFromBrowser = ipc.sendChannelSync('browser-data-request', 'THIS IS FROM THE RENDERER')
console.log 'got this data from the browser', dataFromBrowser

Here is the code to listen for that event on the browser process (in main.coffee):

ipc.on 'browser-data-request', (processId, messageId, message) ->
  console.log 'browser got request', processId, messageId, message
  ipc.sendChannel('window-state', processId, messageId, "THIS SOME DATA FROM THE BROWSER")

The browser ipc callback gets some strange params though, it gets:

{} 2 1 THIS IS FROM THE RENDERER []

Also, the call to sendChannelSync doesn't return THIS IS SOME DATA FROM THE BROWSER it returns undefined.

Am I using this wrong?
Is there a better way to do this?

Activity

  1. zcbenz commented on May 16, 2013

    @zcbenz
    Contributor

    The right way to listen for sync message in browser is:

    ipc.on 'browser-data-request', (event, processId, messageId, message) ->
      event.result = "THIS SOME DATA FROM THE BROWSER" 

    This interface doesn't look very nice, but it's the easiest one to implement. I'll make the document more clear.

  2. probablycorey commented on May 16, 2013

    @probablycorey
    Author

    It's working great now! Thanks!

  3. added a commit that references this issue on Sep 28, 2015
  4. added a commit that references this issue on Feb 16, 2016
  5. added a commit that references this issue on Mar 11, 2016
  6. added 4 commits that reference this issue on May 9, 2017
    ac8bdee
    c9df314
    4fc0fed
    0526aa4
  7. added a commit that references this issue on Jul 6, 2017
  8. added a commit that references this issue on Oct 9, 2017
  9. added a commit that references this issue on May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions