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];