0

I have an NSMenu that I want to update with items pushed to my app through pusherapp and received using the libPusher client library. But events seem not to be received in NSEventTrackingRunLoopMode.

Given the following snippet:

[channel bindToEventNamed:@"my_event" handleWithBlock:^(PTPusherEvent *event) {
    NSLog(@"event received");
}];

And I wait for a push to occur while I maintain the menu open, I expect to receive the event immediately but I only receive it when I close the menu.

I also tried passing the main queue to bindToEventNamed:handleWithBlock:queue: (using dispatch_get_main_queue();), to no avail.

So I'm left wondering whether I'm doing something wrong or there's a bug in libPusher?

Geoffrey Bachelet
  • 4,047
  • 2
  • 21
  • 17
  • take a look at, http://stackoverflow.com/questions/2808016/how-does-apple-update-the-airport-menu-while-it-is-open-how-to-change-nsmenu-w – adc Aug 07 '12 at 15:27
  • Yeah, that's exactly what I'm saying by "events seem not to be received in `NSEventTrackingRunLoopMode`"... – Geoffrey Bachelet Aug 07 '12 at 16:11

1 Answers1

0

I'm the author of libPusher. The reason you are seeing this problem is because the underlying WebSocket library used by libPusher, SocketRocket only works in the default run loop mode.

The good news is that this has been fixed in the latest HEAD of SocketRocket. I have tested libPusher agains the latest SocketRocket and can confirm that it fixes this issue and I intend to roll these changes in to the next release.

Now, I've just checked the outstanding Github issue and realised that you were the original reporter of this bug, so you probably know all this already but I'm going to post this answer anyway for posterity.

Luke Redpath
  • 10,474
  • 3
  • 27
  • 26