Example #1
0
Client::Client( int _udpport )
{
	if(network.simLag > 0)
		ZCom_simulateLag(0, network.simLag);
	if(network.simLoss > 0.f)
		ZCom_simulateLoss(0, network.simLoss);
	if ( !ZCom_initSockets( true,_udpport, 1, 0 ) )
	{
		console.addLogMsg("* ERROR: FAILED TO INITIALIZE SOCKETS");
	}
	ZCom_setControlID(0);
	ZCom_setDebugName("ZCOM_CLI");
	ZCom_setUpstreamLimit(network.upLimit, network.upLimit); 
}
Example #2
0
/***********************************************************************
 * Constructor
 ***********************************************************************/
GameClient::GameClient(unsigned short downpacketpersecond, unsigned short downbyteperpacket)
: m_id(ZCom_Invalid_ID), m_zoi_id(ZCom_Invalid_ID), m_connected(false),  
	m_downpacketpersecond(downpacketpersecond), m_downbyteperpacket(downbyteperpacket),
	m_disconnecting(false), m_callback(NULL)
{
	// this will allocate the sockets and create local bindings
    if ( !ZCom_initSockets( eZCom_EnableUDP, 0, 0, 0 ) )
    {
		LogHandler::getInstance()->LogToFile("Zoid: Failed to initialize sockets!", 2);
    }

    // string shown in log output
    ZCom_setDebugName("ZCOM_GAME_CLI");


	//register classes
	MapInfoObject::registerClass(this);
	ActorObject::registerClass(this);
	PlayerObject::registerClass(this);
}
Example #3
0
/***********************************************************************
 * Constructor
 ***********************************************************************/
MainServerClient::MainServerClient(unsigned short downpacketpersecond, unsigned short downbyteperpacket, 
									GameServerCallbackBase* callbH)
: m_id(ZCom_Invalid_ID), m_zoi_id(ZCom_Invalid_ID), m_connected(false),  
	m_downpacketpersecond(downpacketpersecond), m_downbyteperpacket(downbyteperpacket),	_callbH(callbH)
{
	// this will allocate the sockets and create local bindings
    if ( !ZCom_initSockets( eZCom_EnableUDP, 0, 0, 0 ) )
    {
		LogHandler::getInstance()->LogToFile("Main client: Failed to initialize sockets!", 2);
    }

    // string shown in log output
    ZCom_setDebugName("ZCOM_MainCLI");



	// register classes
	ChatChannelManager::registerClass(this);
	ChatChannel::registerClass(this);
	ClientObject::registerClass(this);
	GameServerHandler::registerClass(this);
}
Example #4
0
Server::Server( int _udpport )
: m_preShutdown(false), socketsInited(false), port(_udpport)
{
	if(network.simLag > 0)
		ZCom_simulateLag(0, network.simLag);
	if(network.simLoss > 0.f)
		ZCom_simulateLoss(0, network.simLoss);

	// TODO: Asynchronize this loop
	int tries = 10;
	bool result = false;
	while ( !result && tries-- > 0 )
	{
		rest(100);
		result = ZCom_initSockets( true, _udpport, 1, 0 );
	}
	if(!result)
		console.addLogMsg("* ERROR: FAILED TO INITIALIZE SOCKETS");

	ZCom_setControlID(0);
	ZCom_setDebugName("ZCOM_CLI");
	ZCom_setUpstreamLimit(network.upLimit, network.upLimit);
	console.addLogMsg("SERVER UP");
}