示例#1
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
xNString xDistributedSession::getPassword()
{

	if (getProperty(E_DC_S_NP_PASSWORD))
	{
		xDistributedString* passwordP= (xDistributedString*)getProperty(E_DC_S_NP_PASSWORD);
		if (passwordP)
		{
			return passwordP->mCurrentValue;
		}
	}
	return xNString("");
}
示例#2
0
xNString ValueTypeToString(int valueType)
{

	switch(valueType)
	{
		case E_DC_PTYPE_3DVECTOR:
			return xNString("3D Vector");
		case E_DC_PTYPE_2DVECTOR:
			return xNString("2D Vector");
		case E_DC_PTYPE_INT:
			return xNString("Integer");
		case E_DC_PTYPE_FLOAT:
			return xNString("Float");
		case E_DC_PTYPE_STRING:
			return xNString("String");
	}

	return xNString("Unknown");
}
示例#3
0
/*
*******************************************************************
* Function:   
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
void xDistributedSession::unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream)
{

	xNetInterface *netInterface  = (xNetInterface*) connection->getInterface();
	if (netInterface)
	{
		//////////////////////////////////////////////////////////////////////////
		//initial update  ? 
		if(stream->readFlag())
		{
			if(stream->readFlag())
			{
				char oName[256];stream->readString(oName);	// retrieve objects name : 
				char cName[256];stream->readString(cName);	// retrieve objects dist class name : 
				int type  = stream->readInt(32);							//read the dist class base type : 
				int userID = stream->readInt(32);	
				int serverID2 = stream->readInt(32);	
				float creationTime = 0.0f;
				stream->read(&creationTime);
				int sessionID = stream->readInt(32);	
				int MaxUsers = stream->readInt(32);	
				char pass[256];stream->readString(pass);





				//////////////////////////////////////////////////////////////////////////
				//now we store all in the dist object :

				//find and store the dist class : 
				xDistributedClassesArrayType *_classes = netInterface->getDistributedClassInterface()->getDistrutedClassesPtr();
				xDistributedClass *classTemplate = netInterface->getDistributedClassInterface()->get(cName,type);
				if (!classTemplate)
				{
					xLogger::xLog(ELOGERROR,E_LI_SESSION,"Warning initial unpack of session %s failed :  no related class found  : %s",oName,cName);
					//xLogger::xLog(ELOGINFO,XL_START,"Warning Initial Unpack Update, no related class found  : %s",cName);
					//xLogger::xLog(ELOGERROR,XL_SESSION,"Warning Initial Unpack Update, no related class found  : %s",cName);
					classTemplate  = netInterface->getDistributedClassInterface()->createClass(cName,type);

				}
				setDistributedClass(classTemplate);
				SetName(oName);
				setServerID(connection->getGhostIndex(this));
				setObjectFlags(E_DO_CREATION_CREATED);
				setUserID(userID);
				setNetInterface(netInterface);
				setCreationTime(creationTime);
				setSessionID(sessionID);
                			
				
				getOwnershipState().set( 1<<E_DO_OS_OWNER,  getUserID() == ((vtConnection*)connection)->getUserID() );

				setInterfaceFlags(E_DO_CREATED);
				getSessionFlags().set( 1 << E_SF_INCOMPLETE );


				xLogger::xLog(ELOGTRACE,E_LI_SESSION,"Retrieved initial state of session %s",oName);
				initProperties();
				setMaxUsers(MaxUsers);
				setPassword(xNString(pass));
				vtConnection *con  = (vtConnection*)connection;
				setOwnerConnection(con);
			}
		}



		int updateBits = stream->readSignedInt(32);
		TNL::BitSet32 updateBitsMask(updateBits);
		setGhostUpdateBits(updateBits);

		xDistributedPropertyArrayType &props = *getDistributedPorperties();
		int propCounter = 0;
		for (unsigned int i = 0  ;  i < props.size() ; i++ )
		{
			xDistributedProperty *prop  = props[i];
			xDistributedPropertyInfo*propInfo  = prop->getPropertyInfo();
			int blockIndex = prop->getBlockIndex();
			if (updateBitsMask.testStrict(1<<blockIndex))
			{
				prop->updateFromServer(stream);
				xLogger::xLog(ELOGTRACE,E_LI_SESSION,"Client : retrieving session property : %s |pred :%d",prop->getPropertyInfo()->mName.getString(),prop->getPropertyInfo()->mPredictionType);
				//xLogger::xLog(ELOGINFO,XL_START,"client : retrieving session property : %s",prop->getPropertyInfo()->mName.getString());
				getSessionFlags().set( 1 << E_SF_COMPLETE );
				propCounter++;
			}
		}

		if (propCounter == props.size())
		{
			getSessionFlags().set( 1 << E_SF_COMPLETE );
		}
	}
}