41
41
static NSString * kInsecureHandshakePortURL = @" http://%@ :%d /socket.io/1/?t=%d %@ " ;
42
42
static NSString * kSecureHandshakePortURL = @" https://%@ :%d /socket.io/1/?t=%d %@ " ;
43
43
static NSString * kSecureHandshakeURL = @" https://%@ /socket.io/1/?t=%d %@ " ;
44
+ static NSString * kForceDisconnectURL = @" %@ ://%@%@ /socket.io/1/xhr-polling/%@ ?disconnect" ;
44
45
45
46
float const defaultConnectionTimeout = 10 .0f ;
46
47
@@ -154,10 +155,8 @@ - (void) connectToHost:(NSString *)host
154
155
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData
155
156
timeoutInterval: connectionTimeout];
156
157
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 ];
161
160
[_handshake start ];
162
161
if (_handshake) {
163
162
_httpRequestData = [NSMutableData data ];
@@ -183,8 +182,10 @@ - (void) disconnect
183
182
- (void ) disconnectForced
184
183
{
185
184
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];
187
187
NSURL *url = [NSURL URLWithString: urlString];
188
+ DEBUGLOG (@" Force disconnect at: %@ " , urlString);
188
189
189
190
NSURLRequest *request = [NSURLRequest requestWithURL: url];
190
191
NSError *error = nil ;
0 commit comments