CheckForResend Resend a connect message if the last one has timed out.
()
| 600 | * Resend a connect message if the last one has timed out. |
| 601 | */ |
| 602 | private static void CheckForResend() { |
| 603 | // if the local server is running and we aren't |
| 604 | // then connect |
| 605 | if (ClientGlobals.cls.state == Defines.ca_disconnected |
| 606 | && Globals.server_state != ServerStates.SS_DEAD) { |
| 607 | ClientGlobals.cls.state = Defines.ca_connecting; |
| 608 | ClientGlobals.cls.servername = "localhost"; |
| 609 | // we don't need a challenge on the localhost |
| 610 | SendConnectPacket(); |
| 611 | return; |
| 612 | } |
| 613 | |
| 614 | // resend if we haven't gotten a reply yet |
| 615 | if (ClientGlobals.cls.state != Defines.ca_connecting) |
| 616 | return; |
| 617 | |
| 618 | if (ClientGlobals.cls.realtime - ClientGlobals.cls.connect_time < 3000) |
| 619 | return; |
| 620 | |
| 621 | netadr_t adr = netadr_t.fromString(ClientGlobals.cls.servername, Defines.PORT_SERVER); |
| 622 | if (adr == null) { |
| 623 | Com.Printf("Bad server address\n"); |
| 624 | ClientGlobals.cls.state = Defines.ca_disconnected; |
| 625 | return; |
| 626 | } |
| 627 | |
| 628 | // for retransmit requests |
| 629 | ClientGlobals.cls.connect_time = ClientGlobals.cls.realtime; |
| 630 | |
| 631 | Com.Printf("Connecting to " + ClientGlobals.cls.servername + "...\n"); |
| 632 | |
| 633 | Netchan.sendConnectionlessPacket(Defines.NS_CLIENT, adr, ConnectionlessCommand.getchallenge, "\n"); |
| 634 | } |
| 635 | |
| 636 | /** |
| 637 | * ClearState |
no test coverage detected