MegaBits/SIOSocket — pull request #28 by jonathannorris (2014-11-18 01:28:38+00:00)
Title: Ensure that all block callbacks are on Main Thread

I believe that the majority of issues that people have been seeing with instability on iOS 8 (specifically #16) are because most of the callback blocks are running on a WebThread and not the Main Thread. You can see this by adding a log for the current thread in one of the return blocks:

```
socket.javascriptContext[@"objc_onConnect"] = ^() {
NSLog(@"javascript thread: %@", [NSThread currentThread]);

dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"main thread: %@", [NSThread currentThread]);
if (weakSocket.onConnect)
weakSocket.onConnect();
});
};
```
Obviously all callbacks should be called from the main thread.