void AccessConfig::assign(const AccessConfig& s) { setUsername (s.getUsername() ); setPassword (s.getPassword() ); setSyncURL (s.getSyncURL() ); setProxyHost(s.getProxyHost()); setProxyPort(s.getProxyPort()); setUserAgent(s.getUserAgent()); setProxyUsername(s.getProxyUsername()); setProxyPassword(s.getProxyPassword()); setBeginSync(s.getBeginSync()); setEndSync(s.getEndSync()); setFirstTimeSyncMode(s.getFirstTimeSyncMode()); setServerAuthRequired(s.getServerAuthRequired()); setClientAuthType(s.getClientAuthType()); setServerAuthType(s.getServerAuthType()); setServerPWD(s.getServerPWD()); setServerID(s.getServerID()); setServerNonce(s.getServerNonce()); setClientNonce(s.getClientNonce()); setMaxMsgSize(s.getMaxMsgSize()); setReadBufferSize(s.getReadBufferSize()); setCheckConn(s.getCheckConn()); setResponseTimeout(s.getResponseTimeout()); setCompression(s.getCompression()); dirty = s.getDirty(); }
void xDistributedSession::onGhostAvailable(TNL::GhostConnection *theConnection) { Parent::onGhostAvailable(theConnection); int conID = ((vtConnection*)theConnection)->getUserID(); //xLogger::xLog(ELOGINFO,XL_START, "session ghost available %d",conID); xDistributedPropertyArrayType &props = *getDistributedPorperties(); for (unsigned int i = 0 ; i < props.size() ; i++ ) { xDistributedProperty *prop = props[i]; xDistributedPropertyInfo*propInfo = prop->getPropertyInfo(); int blockIndex = prop->getBlockIndex(); if (propInfo) { if (getUpdateBits().set(1<<blockIndex),true) { } setMaskBits(1<<blockIndex); } } xNetInterface *netInterface = (xNetInterface*) theConnection->getInterface(); if (netInterface->IsServer()) { setServerID(theConnection->getGhostIndex((TNL::NetObject*)this)); //xLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION, "ServerID %d | Name : %s",getServerID(),GetName().getString()); } }
/* ******************************************************************* * 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 ); } } }
/* ******************************************************************* * Function: * * Description: * * Parameters: * * Returns: * ******************************************************************* */ TNL::U32 xDistributedSession::packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream) { xNetInterface *netInterface = (xNetInterface*) connection->getInterface(); if (netInterface) { //the first time ? : we write out all necessary attributes for the client : if(stream->writeFlag(updateMask & InitialMask)) { if(stream->writeFlag(true)) { //write out name : stream->writeString(GetName().getString(),strlen(GetName().getString())); //retrieve its class : xDistributedClass *distClass = getDistributedClass(); if (distClass) { //write out the class name : stream->writeString(distClass->getClassName().getString(),strlen(distClass->getClassName().getString())); //write out the class base type : stream->writeInt(distClass->getEnitityType(),32); //write out users id : vtConnection *con = (vtConnection*)connection; int uid = getUserID(); stream->writeInt(getUserID(),32); //write out server side id : int serverID = connection->getGhostIndex(this); stream->writeInt(connection->getGhostIndex(this),32); setServerID(connection->getGhostIndex(this)); float time = getCreationTime(); //write out creation time stream->write(getCreationTime()); // xLogger::xLog(ELOGINFO,XL_START,"server:init pack update of %s: %f , %d , ",GetName().getString(),time,uid); stream->writeInt(getSessionID(),32); stream->writeInt(getMaxUsers(),32); stream->writeString(getPassword().getString(),strlen(getPassword().getString())); //netInterface->deploySessionClasses(connection); } setNetInterface(netInterface); } } /************************************************************************/ /* */ /************************************************************************/ stream->writeSignedInt(getUpdateBits().getMask(),32); //xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d", getUpdateBits().getMask() ); xDistributedPropertyArrayType &props = *getDistributedPorperties(); for (unsigned int i = 0 ; i < props.size() ; i++ ) { xDistributedProperty *prop = props[i]; xDistributedPropertyInfo*propInfo = prop->getPropertyInfo(); int blockIndex = prop->getBlockIndex(); if (propInfo) { if (getUpdateBits().testStrict(1<<blockIndex)) { prop->updateGhostValue(stream); //xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d",blockIndex); } } } //getUpdateBits().clear(); } return 0; }