MCPcopy Create free account
hub / github.com/demoth/jake2 / CL_ReadPackets

Method CL_ReadPackets

client/src/main/java/jake2/client/CL.java:780–824  ·  view source on GitHub ↗

ReadPackets

()

Source from the content-addressed store, hash-verified

778 * ReadPackets
779 */
780 private static void CL_ReadPackets() {
781 while (true) {
782 NetworkPacket networkPacket = NET.receiveNetworkPacket(
783 NET.ip_sockets[NS_CLIENT],
784 NET.ip_channels[NS_CLIENT],
785 NET.loopbacks[NS_CLIENT],
786 false);
787
788 if (networkPacket == null)
789 break;
790
791 if (networkPacket.isConnectionless()) {
792 CL_ConnectionlessPacket(networkPacket);
793 continue;
794 }
795
796 if (ClientGlobals.cls.state == Defines.ca_disconnected
797 || ClientGlobals.cls.state == Defines.ca_connecting)
798 continue; // dump it if not connected
799
800 //
801 // packet from server
802 //
803 if (!networkPacket.from.compareIp(ClientGlobals.cls.netchan.remote_address)) {
804 Com.DPrintf(networkPacket.from + ":sequenced packet without connection\n");
805 continue;
806 }
807 if (ClientGlobals.cls.netchan.accept(networkPacket)) {
808 CL_parse.ParseServerMessage(networkPacket.parseBodyFromServer());
809 } //else wasn't accepted for some reason
810 }
811
812 //
813 // check timeout
814 //
815 if (ClientGlobals.cls.state >= Defines.ca_connected
816 && ClientGlobals.cls.realtime - ClientGlobals.cls.netchan.last_received > ClientGlobals.cl_timeout.value * 1000) {
817 if (++ClientGlobals.cl.timeoutcount > 5) // timeoutcount saves debugger
818 {
819 Com.Printf("\nServer connection timed out.\n");
820 Disconnect();
821 }
822 } else
823 ClientGlobals.cl.timeoutcount = 0;
824 }
825
826 // =============================================================================
827

Callers 1

FrameMethod · 0.95

Calls 10

receiveNetworkPacketMethod · 0.95
isConnectionlessMethod · 0.95
DPrintfMethod · 0.95
ParseServerMessageMethod · 0.95
parseBodyFromServerMethod · 0.95
PrintfMethod · 0.95
DisconnectMethod · 0.95
compareIpMethod · 0.80
acceptMethod · 0.45

Tested by

no test coverage detected