This repository was archived by the owner on May 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ typedef enum {
75
75
BOOL _isConnecting;
76
76
BOOL _useSecure;
77
77
78
+ NSURLConnection *_handshake;
79
+
78
80
// heartbeat
79
81
NSTimeInterval _heartbeatTimeout;
80
82
NSTimer *_timeout;
Original file line number Diff line number Diff line change @@ -138,21 +138,26 @@ - (void) connectToHost:(NSString *)host onPort:(NSInteger)port withParams:(NSDic
138
138
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData
139
139
timeoutInterval: 10.0 ];
140
140
141
- NSURLConnection *connection = [NSURLConnection connectionWithRequest: request
142
- delegate: self ];
143
- if (connection ) {
141
+ _handshake = [NSURLConnection connectionWithRequest: request
142
+ delegate: self ];
143
+ if (_handshake ) {
144
144
_httpRequestData = [NSMutableData data ];
145
145
}
146
146
else {
147
147
// connection failed
148
- [self connection: connection didFailWithError: nil ];
148
+ [self connection: _handshake didFailWithError: nil ];
149
149
}
150
150
}
151
151
}
152
152
153
153
- (void ) disconnect
154
154
{
155
- [self sendDisconnect ];
155
+ if (_isConnected) {
156
+ [self sendDisconnect ];
157
+ }
158
+ else if (_isConnecting) {
159
+ [_handshake cancel ];
160
+ }
156
161
}
157
162
158
163
- (void ) sendMessage : (NSString *)data
You can’t perform that action at this time.
0 commit comments