Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit afacfb9

Browse files
committed
adjust the forced disconnect method a bit
1 parent 030abe1 commit afacfb9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

SocketIO.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
static NSString* kInsecureHandshakePortURL = @"http://%@:%d/socket.io/1/?t=%d%@";
4242
static NSString* kSecureHandshakePortURL = @"https://%@:%d/socket.io/1/?t=%d%@";
4343
static NSString* kSecureHandshakeURL = @"https://%@/socket.io/1/?t=%d%@";
44+
static NSString* kForceDisconnectURL = @"%@://%@%@/socket.io/1/xhr-polling/%@?disconnect";
4445

4546
float const defaultConnectionTimeout = 10.0f;
4647

@@ -154,10 +155,8 @@ - (void) connectToHost:(NSString *)host
154155
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
155156
timeoutInterval:connectionTimeout];
156157

157-
_handshake = [[NSURLConnection alloc] initWithRequest:request
158-
delegate:self startImmediately:NO];
159-
[_handshake scheduleInRunLoop:[NSRunLoop mainRunLoop]
160-
forMode:NSDefaultRunLoopMode];
158+
_handshake = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
159+
[_handshake scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
161160
[_handshake start];
162161
if (_handshake) {
163162
_httpRequestData = [NSMutableData data];
@@ -183,8 +182,10 @@ - (void) disconnect
183182
- (void) disconnectForced
184183
{
185184
NSString *protocol = [self useSecure] ? @"https" : @"http";
186-
NSString *urlString = [NSString stringWithFormat:@"%@://%@:%i/socket.io/1/xhr-polling/%@?disconnect", protocol, _host, _port, _sid];
185+
NSString *port = _port ? [NSString stringWithFormat:@":%d", _port] : @"";
186+
NSString *urlString = [NSString stringWithFormat:kForceDisconnectURL, protocol, _host, port, _sid];
187187
NSURL *url = [NSURL URLWithString:urlString];
188+
DEBUGLOG(@"Force disconnect at: %@", urlString);
188189

189190
NSURLRequest *request = [NSURLRequest requestWithURL:url];
190191
NSError *error = nil;

0 commit comments

Comments
 (0)