File tree 1 file changed +16
-11
lines changed
src/main/java/io/socket/client
1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -271,23 +271,28 @@ public void call(Object... objects) {
271
271
}
272
272
});
273
273
274
- if (Manager .this ._timeout >= 0 ) {
275
- final long timeout = Manager .this ._timeout ;
274
+ final long timeout = Manager .this ._timeout ;
275
+ final Runnable onTimeout = new Runnable () {
276
+ @ Override
277
+ public void run () {
278
+ logger .fine (String .format ("connect attempt timed out after %d" , timeout ));
279
+ openSub .destroy ();
280
+ socket .close ();
281
+ socket .emit (Engine .EVENT_ERROR , new SocketIOException ("timeout" ));
282
+ }
283
+ };
284
+
285
+ if (timeout == 0 ) {
286
+ EventThread .exec (onTimeout );
287
+ return ;
288
+ } else if (Manager .this ._timeout > 0 ) {
276
289
logger .fine (String .format ("connection attempt will timeout after %d" , timeout ));
277
290
278
291
final Timer timer = new Timer ();
279
292
timer .schedule (new TimerTask () {
280
293
@ Override
281
294
public void run () {
282
- EventThread .exec (new Runnable () {
283
- @ Override
284
- public void run () {
285
- logger .fine (String .format ("connect attempt timed out after %d" , timeout ));
286
- openSub .destroy ();
287
- socket .close ();
288
- socket .emit (Engine .EVENT_ERROR , new SocketIOException ("timeout" ));
289
- }
290
- });
295
+ EventThread .exec (onTimeout );
291
296
}
292
297
}, timeout );
293
298
You can’t perform that action at this time.
0 commit comments