engine/EngineClientParse.c
/*	When the client is taking a long time to load stuff, send keepalive messages
	so the server doesn't disconnect.
*/
When the client is taking a long time to load stuff, send keepalive messages
so the server doesn't disconnect.
When the client is taking a long time to load stuff send keepalive messages so the server doesn ' t disconnect .
void CL_KeepaliveMessage (void)
{
	float	time;
	static float lastmsg;
	int		ret;
	sizebuf_t	old;
	byte		olddata[8192];
	if (sv.active)
		return;		
	if (cls.demoplayback)
		return;
	old = net_message;
	memcpy (olddata, net_message.data, net_message.cursize);
	do
	{
		ret = CL_GetMessage ();
		switch (ret)
		{
		default:
			Host_Error ("CL_KeepaliveMessage: CL_GetMessage failed");
		case 0:
			break;	
		case 1:
			Host_Error ("CL_KeepaliveMessage: received a message");
			break;
		case 2:
			if(MSG_ReadByte() != SVC_NOP)
				Host_Error("CL_KeepaliveMessage: datagram wasn't a nop");
			break;
		}
	} while (ret);
	net_message = old;
	memcpy (net_message.data, olddata, net_message.cursize);
	time = System_DoubleTime ();
	if (time - lastmsg < 5)
		return;
	lastmsg = time;
	Con_DPrintf ("--> client to server keepalive\n");
	MSG_WriteByte (&cls.message, clc_nop);
	NET_SendMessage (cls.netcon, &cls.message);
	SZ_Clear (&cls.message);
}
void CL_KeepaliveMessage ( void ) { float time ; static float lastmsg ; int ret ; sizebuf_t old ; byte olddata [ 8192 ] ; if ( sv . active ) return ; if ( cls . demoplayback ) return ; old = net_message ; memcpy ( olddata , net_message . data , net_message . cursize ) ; do { ret = CL_GetMessage ( ) ; switch ( ret ) { default : Host_Error ( " " ) ; case 0 : break ; case 1 : Host_Error ( " " ) ; break ; case 2 : if ( MSG_ReadByte ( ) != SVC_NOP ) Host_Error ( " " ) ; break ; } } while ( ret ) ; net_message = old ; memcpy ( net_message . data , olddata , net_message . cursize ) ; time = System_DoubleTime ( ) ; if ( time - lastmsg < 5 ) return ; lastmsg = time ; Con_DPrintf ( " \n " ) ; MSG_WriteByte ( & cls . message , clc_nop ) ; NET_SendMessage ( cls . netcon , & cls . message ) ; SZ_Clear ( & cls . message ) ; }
When the client is taking a long time to load stuff, send keepalive messages
so the server doesn't disconnect.
When the client is taking a long time to load stuff send keepalive messages so the server doesn ' t disconnect .
// no need if server is local // read messages from server, should just be nops // nothing waiting // check time // write out a nop