File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
src/main/java/io/socket/client Expand file tree Collapse file tree 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) {
271271 }
272272 });
273273
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 ) {
276289 logger .fine (String .format ("connection attempt will timeout after %d" , timeout ));
277290
278291 final Timer timer = new Timer ();
279292 timer .schedule (new TimerTask () {
280293 @ Override
281294 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 );
291296 }
292297 }, timeout );
293298
You can’t perform that action at this time.
0 commit comments