Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SocketIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ typedef enum {
@property (nonatomic, readonly) NSString *sid;
@property (nonatomic, readonly) NSTimeInterval heartbeatTimeout;
@property (nonatomic) BOOL useSecure;
@property (nonatomic) NSString *path;
@property (nonatomic) NSArray *cookies;
@property (nonatomic, readonly) BOOL isConnected, isConnecting;
@property (nonatomic, weak) id<SocketIODelegate> delegate;
Expand Down
11 changes: 6 additions & 5 deletions SocketIO.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
#define DEBUGLOG(...)
#endif

static NSString* kResourceName = @"socket.io";
static NSString* kResourceName = @"/socket.io";
static NSString* kTransportPolling = @"polling";
static NSString* kTransportWebsocket = @"websocket";
static NSString* kHandshakeURL = @"%@://%@%@/%@/1/?EIO=2&transport=%@&t=%.0f%@";
static NSString* kForceDisconnectURL = @"%@://%@%@/%@/1/xhr-polling/%@?disconnect";
static NSString* kHandshakeURL = @"%@://%@%@%@%@/1/?EIO=2&transport=%@&t=%.0f%@";
static NSString* kForceDisconnectURL = @"%@://%@%@%@%@/1/xhr-polling/%@?disconnect";

float const defaultConnectionTimeout = 10.0f;

Expand Down Expand Up @@ -91,6 +91,7 @@ - (id) initWithDelegate:(id<SocketIODelegate>)delegate
_ackCount = 0;
_acks = [[NSMutableDictionary alloc] init];
_returnAllDataFromAck = NO;
_path=@"";
}
return self;
}
Expand Down Expand Up @@ -137,7 +138,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,kTransportPolling, time, query];
NSString *handshakeUrl = [NSString stringWithFormat:kHandshakeURL, protocol, _host, port, _path, kResourceName,kTransportPolling, time, query];
//@"%@://%@%@/%@/1/?t=%.0f%@";
//http://<host><port>/socket.io/1/?t=<time>f<query>

Expand Down Expand Up @@ -186,7 +187,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, _path, kResourceName, _sid];
NSURL *url = [NSURL URLWithString:urlString];
DEBUGLOG(@"Force disconnect at: %@", urlString);

Expand Down
1 change: 1 addition & 0 deletions SocketIOTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef enum SocketIOVersion
@property (nonatomic, readonly) NSString *sid;
@property (nonatomic, readonly) NSTimeInterval heartbeatTimeout;
@property (nonatomic) BOOL useSecure;
@property (nonatomic) NSString *path;

@end

Expand Down
12 changes: 6 additions & 6 deletions SocketIOTransportWebsocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -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://%@%@/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/%@%@";

@implementation SocketIOTransportWebsocket

Expand Down Expand Up @@ -68,11 +68,11 @@ - (void) openUsing:(SocketIOVersion)version

if (delegate.port) {
format = delegate.useSecure ? kSecureSocketPortURL : kInsecureSocketPortURL;
urlStr = [NSString stringWithFormat:format, delegate.host, delegate.port, addOnVersion, delegate.sid];
urlStr = [NSString stringWithFormat:format, delegate.host, delegate.port, delegate.path, addOnVersion, delegate.sid];
}
else {
format = delegate.useSecure ? kSecureSocketURL : kInsecureSocketURL;
urlStr = [NSString stringWithFormat:format, delegate.host,addOnVersion, delegate.sid];
urlStr = [NSString stringWithFormat:format, delegate.host, delegate.path, addOnVersion, delegate.sid];
}
NSURL *url = [NSURL URLWithString:urlStr];

Expand Down
12 changes: 6 additions & 6 deletions SocketIOTransportXHR.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#define DEBUGLOG(...)
#endif

static NSString* kInsecureXHRURL = @"http://%@/socket.io/1/xhr-polling/%@";
static NSString* kSecureXHRURL = @"https://%@/socket.io/1/xhr-polling/%@";
static NSString* kInsecureXHRPortURL = @"http://%@:%d/socket.io/1/xhr-polling/%@";
static NSString* kSecureXHRPortURL = @"https://%@:%d/socket.io/1/xhr-polling/%@";
static NSString* kInsecureXHRURL = @"http://%@%@/socket.io/1/xhr-polling/%@";
static NSString* kSecureXHRURL = @"https://%@%@/socket.io/1/xhr-polling/%@";
static NSString* kInsecureXHRPortURL = @"http://%@:%d%@/socket.io/1/xhr-polling/%@";
static NSString* kSecureXHRPortURL = @"https://%@:%d%@/socket.io/1/xhr-polling/%@";

@interface SocketIOTransportXHR (Private)
- (void) checkAndStartPoll;
Expand Down Expand Up @@ -67,11 +67,11 @@ - (void) openUsing:(SocketIOVersion)version
NSString *format;
if (delegate.port) {
format = delegate.useSecure ? kSecureXHRPortURL : kInsecureXHRPortURL;
_url = [NSString stringWithFormat:format, delegate.host, delegate.port, delegate.sid];
_url = [NSString stringWithFormat:format, delegate.host, delegate.port, delegate.path, delegate.sid];
}
else {
format = delegate.useSecure ? kSecureXHRURL : kInsecureXHRURL;
_url = [NSString stringWithFormat:format, delegate.host, delegate.sid];
_url = [NSString stringWithFormat:format, delegate.host, delegate.path, delegate.sid];
}
DEBUGLOG(@"Opening XHR @ %@", _url);
[self poll:nil];
Expand Down