From 7a14cb8e4cf773b54b3480e2ae5a0783a0dacab0 Mon Sep 17 00:00:00 2001 From: Ely Deckers Date: Thu, 17 Apr 2014 17:41:53 +0200 Subject: [PATCH 1/5] * The resource part of the websocket-url did not take into account the value set via setResourceName, but always used the static value "socket.io" instead. --- SocketIO.h | 1 + SocketIO.m | 7 +++---- SocketIOTransport.h | 1 + SocketIOTransportWebsocket.m | 12 ++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/SocketIO.h b/SocketIO.h index 2fbb12e..8880539 100755 --- a/SocketIO.h +++ b/SocketIO.h @@ -91,6 +91,7 @@ typedef enum { } @property (nonatomic, readonly) NSString *host; +@property (nonatomic, readonly) NSString *resourceName; @property (nonatomic, readonly) NSInteger port; @property (nonatomic, readonly) NSString *sid; @property (nonatomic, readonly) NSTimeInterval heartbeatTimeout; diff --git a/SocketIO.m b/SocketIO.m index 61ff67a..692e1d0 100755 --- a/SocketIO.m +++ b/SocketIO.m @@ -36,7 +36,6 @@ #define DEBUGLOG(...) #endif -static NSString* kResourceName = @"socket.io"; static NSString* kHandshakeURL = @"%@://%@%@/%@/1/?t=%.0f%@"; static NSString* kForceDisconnectURL = @"%@://%@%@/%@/1/xhr-polling/%@?disconnect"; @@ -136,7 +135,7 @@ - (void) connectToHost:(NSString *)host NSString *protocol = _useSecure ? @"https" : @"http"; NSString *port = _port ? [NSString stringWithFormat:@":%d", _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, _resourceName, time, query]; DEBUGLOG(@"Connecting to socket with URL: %@", handshakeUrl); query = nil; @@ -183,7 +182,7 @@ - (void) disconnectForced { NSString *protocol = [self useSecure] ? @"https" : @"http"; NSString *port = _port ? [NSString stringWithFormat:@":%d", _port] : @""; - NSString *urlString = [NSString stringWithFormat:kForceDisconnectURL, protocol, _host, port, kResourceName, _sid]; + NSString *urlString = [NSString stringWithFormat:kForceDisconnectURL, protocol, _host, port, _resourceName, _sid]; NSURL *url = [NSURL URLWithString:urlString]; DEBUGLOG(@"Force disconnect at: %@", urlString); @@ -261,7 +260,7 @@ - (void) sendAcknowledgement:(NSString *)pId withArgs:(NSArray *)data - (void) setResourceName:(NSString *)name { - kResourceName = [name copy]; + _resourceName = [name copy]; } # pragma mark - diff --git a/SocketIOTransport.h b/SocketIOTransport.h index 9f8f7be..bdef25b 100644 --- a/SocketIOTransport.h +++ b/SocketIOTransport.h @@ -28,6 +28,7 @@ @property (nonatomic, readonly) NSString *host; @property (nonatomic, readonly) NSInteger port; +@property (nonatomic, readonly) NSString *resourceName; @property (nonatomic, readonly) NSString *sid; @property (nonatomic, readonly) NSTimeInterval heartbeatTimeout; @property (nonatomic) BOOL useSecure; diff --git a/SocketIOTransportWebsocket.m b/SocketIOTransportWebsocket.m index 5b1579b..11fddbd 100644 --- a/SocketIOTransportWebsocket.m +++ b/SocketIOTransportWebsocket.m @@ -29,10 +29,10 @@ #define DEBUGLOG(...) #endif -static NSString* kInsecureSocketURL = @"ws://%@/socket.io/1/websocket/%@"; -static NSString* kSecureSocketURL = @"wss://%@/socket.io/1/websocket/%@"; -static NSString* kInsecureSocketPortURL = @"ws://%@:%d/socket.io/1/websocket/%@"; -static NSString* kSecureSocketPortURL = @"wss://%@:%d/socket.io/1/websocket/%@"; +static NSString* kInsecureSocketURL = @"ws://%@/%@/1/websocket/%@"; +static NSString* kSecureSocketURL = @"wss://%@/%@/1/websocket/%@"; +static NSString* kInsecureSocketPortURL = @"ws://%@:%d/%@/1/websocket/%@"; +static NSString* kSecureSocketPortURL = @"wss://%@:%d/%@/1/websocket/%@"; @implementation SocketIOTransportWebsocket @@ -58,11 +58,11 @@ - (void) open NSString *format; if (delegate.port) { format = delegate.useSecure ? kSecureSocketPortURL : kInsecureSocketPortURL; - urlStr = [NSString stringWithFormat:format, delegate.host, delegate.port, delegate.sid]; + urlStr = [NSString stringWithFormat:format, delegate.host, delegate.port, delegate.resourceName, delegate.sid]; } else { format = delegate.useSecure ? kSecureSocketURL : kInsecureSocketURL; - urlStr = [NSString stringWithFormat:format, delegate.host, delegate.sid]; + urlStr = [NSString stringWithFormat:format, delegate.host, delegate.resourceName, delegate.sid]; } NSURL *url = [NSURL URLWithString:urlStr]; From 89e190864c7fb0ef652ff07bd4995d4fa6881c95 Mon Sep 17 00:00:00 2001 From: Ely Deckers Date: Fri, 18 Apr 2014 00:46:51 +0200 Subject: [PATCH 2/5] Create .podspec Added .podspec so this repository can be used in projects, until the official project is fixed. --- .podspec | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .podspec diff --git a/.podspec b/.podspec new file mode 100644 index 0000000..2738a08 --- /dev/null +++ b/.podspec @@ -0,0 +1,19 @@ +Pod::Spec.new do |s| + s.name = "socket.IO" + s.version = "0.2.5" + s.summary = "socket.io v0.7.2+ for iOS devices." + s.description = <<-DESC + Interface to communicate between Objective C and Socket.IO with the help of websockets. It's based on fpotter's socketio-cocoa and uses other libraries/classes like SocketRocket, json-framework (optional) and jsonkit (optional). + DESC + s.homepage = "https://github.com/pkyeck/socket.IO-objc" + s.license = 'MIT' + + s.author = { "Philipp Kyeck" => "philipp@beta-interactive.de" } + s.source = { :git => "https://github.com/pkyeck/socket.IO-objc.git", :tag => '0.2.5' } + + s.source_files = '*.{h,m}' + + s.requires_arc = true + + s.dependency 'SocketRocket', '~> 0.2' +end From 193513b571d5d50b97627b9fc9207f32874262d8 Mon Sep 17 00:00:00 2001 From: Ely Deckers Date: Fri, 18 Apr 2014 09:25:47 +0200 Subject: [PATCH 3/5] Delete .podspec --- .podspec | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .podspec diff --git a/.podspec b/.podspec deleted file mode 100644 index 2738a08..0000000 --- a/.podspec +++ /dev/null @@ -1,19 +0,0 @@ -Pod::Spec.new do |s| - s.name = "socket.IO" - s.version = "0.2.5" - s.summary = "socket.io v0.7.2+ for iOS devices." - s.description = <<-DESC - Interface to communicate between Objective C and Socket.IO with the help of websockets. It's based on fpotter's socketio-cocoa and uses other libraries/classes like SocketRocket, json-framework (optional) and jsonkit (optional). - DESC - s.homepage = "https://github.com/pkyeck/socket.IO-objc" - s.license = 'MIT' - - s.author = { "Philipp Kyeck" => "philipp@beta-interactive.de" } - s.source = { :git => "https://github.com/pkyeck/socket.IO-objc.git", :tag => '0.2.5' } - - s.source_files = '*.{h,m}' - - s.requires_arc = true - - s.dependency 'SocketRocket', '~> 0.2' -end From dccc34ff9f6c820431cf3dd9e18b1eb697ae5d06 Mon Sep 17 00:00:00 2001 From: Ely Deckers Date: Fri, 18 Apr 2014 09:26:44 +0200 Subject: [PATCH 4/5] Create .podspec --- .podspec | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .podspec diff --git a/.podspec b/.podspec new file mode 100644 index 0000000..2738a08 --- /dev/null +++ b/.podspec @@ -0,0 +1,19 @@ +Pod::Spec.new do |s| + s.name = "socket.IO" + s.version = "0.2.5" + s.summary = "socket.io v0.7.2+ for iOS devices." + s.description = <<-DESC + Interface to communicate between Objective C and Socket.IO with the help of websockets. It's based on fpotter's socketio-cocoa and uses other libraries/classes like SocketRocket, json-framework (optional) and jsonkit (optional). + DESC + s.homepage = "https://github.com/pkyeck/socket.IO-objc" + s.license = 'MIT' + + s.author = { "Philipp Kyeck" => "philipp@beta-interactive.de" } + s.source = { :git => "https://github.com/pkyeck/socket.IO-objc.git", :tag => '0.2.5' } + + s.source_files = '*.{h,m}' + + s.requires_arc = true + + s.dependency 'SocketRocket', '~> 0.2' +end From 37240a65decd6bdacccc8480db619300915fcf36 Mon Sep 17 00:00:00 2001 From: Ely Deckers Date: Fri, 18 Apr 2014 09:29:15 +0200 Subject: [PATCH 5/5] Delete .podspec --- .podspec | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .podspec diff --git a/.podspec b/.podspec deleted file mode 100644 index 2738a08..0000000 --- a/.podspec +++ /dev/null @@ -1,19 +0,0 @@ -Pod::Spec.new do |s| - s.name = "socket.IO" - s.version = "0.2.5" - s.summary = "socket.io v0.7.2+ for iOS devices." - s.description = <<-DESC - Interface to communicate between Objective C and Socket.IO with the help of websockets. It's based on fpotter's socketio-cocoa and uses other libraries/classes like SocketRocket, json-framework (optional) and jsonkit (optional). - DESC - s.homepage = "https://github.com/pkyeck/socket.IO-objc" - s.license = 'MIT' - - s.author = { "Philipp Kyeck" => "philipp@beta-interactive.de" } - s.source = { :git => "https://github.com/pkyeck/socket.IO-objc.git", :tag => '0.2.5' } - - s.source_files = '*.{h,m}' - - s.requires_arc = true - - s.dependency 'SocketRocket', '~> 0.2' -end