diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea27ee..d8e6d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.5.2 (2014-03-23) + + - check HTTP status code of NSURLConnection responses during xhr polling transport + + ## 0.5.1 (2014-03-14) - add method to pass cookies on handshake diff --git a/README.md b/README.md index 2e8fca9..16b34b2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +**This fork supports some socket.io v1.x features, (no binary support yet). Many thanks to francoisTemasys who did most of the heavy lifting; this is a fork of a fork. v0.9.x compatibility is generally maintained. + + +--- + # Socket.IO / Objective C Library Interface to communicate between Objective C and [Socket.IO](http://socket.io/) @@ -10,8 +15,7 @@ ## Requirements -As of version 0.4, this library requires at least OS X 10.7 or iOS 5.0. -Because of this, we were able to remove the external JSON frameworks in v0.5 and only rely on iOS' own `NSJSONSerialization`. +This library requires at least OS X 10.7 or iOS 5.0. ## Usage diff --git a/SocketIO.h b/SocketIO.h index 2fbb12e..67ceb23 100755 --- a/SocketIO.h +++ b/SocketIO.h @@ -21,6 +21,7 @@ #import #import "SocketIOTransport.h" +#import "SocketIOPacket.h" @class SocketIO; @class SocketIOPacket; @@ -41,6 +42,7 @@ typedef enum { } SocketIOErrorCodes; + @protocol SocketIODelegate @optional - (void) socketIODidConnect:(SocketIO *)socket; @@ -61,6 +63,8 @@ typedef enum { NSString *_endpoint; NSDictionary *_params; + SocketIOVersion _version; + __weak id _delegate; NSObject *_transport; @@ -75,7 +79,9 @@ typedef enum { // heartbeat NSTimeInterval _heartbeatTimeout; + NSTimeInterval _connectionTimeout; dispatch_source_t _timeout; + dispatch_source_t _heartbeat; NSMutableArray *_queue; diff --git a/SocketIO.m b/SocketIO.m index 61ff67a..0b2c455 100755 --- a/SocketIO.m +++ b/SocketIO.m @@ -37,7 +37,9 @@ #endif static NSString* kResourceName = @"socket.io"; -static NSString* kHandshakeURL = @"%@://%@%@/%@/1/?t=%.0f%@"; +static NSString* kTransportPolling = @"polling"; +static NSString* kTransportWebsocket = @"websocket"; +static NSString* kHandshakeURL = @"%@://%@%@/%@/1/?EIO=2&transport=%@&t=%.0f%@"; static NSString* kForceDisconnectURL = @"%@://%@%@/%@/1/xhr-polling/%@?disconnect"; float const defaultConnectionTimeout = 10.0f; @@ -55,11 +57,10 @@ - (NSArray*) arrayOfCaptureComponentsMatchedByRegex:(NSString*)regex; - (void) setTimeout; - (void) onTimeout; +- (void) sendHeartbeat; - (void) onConnect:(SocketIOPacket *)packet; - (void) onDisconnect:(NSError *)error; - - (void) sendDisconnect; -- (void) sendHearbeat; - (void) send:(SocketIOPacket *)packet; - (NSString *) addAcknowledge:(SocketIOCallback)function; @@ -134,9 +135,11 @@ - (void) connectToHost:(NSString *)host // do handshake via HTTP request NSString *protocol = _useSecure ? @"https" : @"http"; - NSString *port = _port ? [NSString stringWithFormat:@":%d", _port] : @""; + NSString *port = _port ? [NSString stringWithFormat:@":%ld", (long)_port] : @""; NSTimeInterval time = [[NSDate date] timeIntervalSince1970] * 1000; - NSString *handshakeUrl = [NSString stringWithFormat:kHandshakeURL, protocol, _host, port, kResourceName, time, query]; + NSString *handshakeUrl = [NSString stringWithFormat:kHandshakeURL, protocol, _host, port, kResourceName,kTransportPolling, time, query]; + //@"%@://%@%@/%@/1/?t=%.0f%@"; + //http:///socket.io/1/?t=