当前位置: 首页>>代码示例>>C++>>正文


C++ TServiceId类代码示例

本文整理汇总了C++中TServiceId的典型用法代码示例。如果您正苦于以下问题:C++ TServiceId类的具体用法?C++ TServiceId怎么用?C++ TServiceId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TServiceId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: decodeUnifiedName

// decode a service in a form 'alias/shortname-sid'
void decodeUnifiedName(const string &unifiedName, string &alias, string &shortName, TServiceId &sid)
{
	size_t pos1 = 0, pos2 = 0;
	pos1 = unifiedName.find("/");
	if (pos1 != string::npos)
	{
		alias = unifiedName.substr(0, pos1);
		pos1++;
	}
	else
	{
		alias = "";
		pos1 = 0;
	}
	pos2 = unifiedName.find("-");
	if (pos2 != string::npos)
	{
		shortName = unifiedName.substr(pos1,pos2-pos1);
		sid.set(atoi(unifiedName.substr(pos2+1).c_str()));
	}
	else
	{
		shortName = unifiedName.substr(pos1);
		sid.set(0);
	}

	if (alias.empty())
	{
		alias = shortName;
	}
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:32,代码来源:admin_executor_service.cpp

示例2: cbPosition

	static void cbPosition(CMessage &msgin, const std::string &serviceName, TServiceId sid)
	{
		// temp
		uint32 id;
		CVector position;
		msgin.serial(id);
		msgin.serial(position);
		nldebug("Received CLS_POSITION, %s %s", serviceName.c_str(), sid.toString().c_str());

		// Update position information in the player list
		_pmap::iterator ItPlayer;
		ItPlayer = playerList.find( id );
		if ( ItPlayer == playerList.end() )
		{
			nlwarning( "Player id %u not found !", id );
		}
		else
		{
			((*ItPlayer).second).position = position;
			//nldebug( "SB: Player position updated" );
		}

		CMessage msgout("ENTITY_TP");
		msgout.serial(id);
		msgout.serial(position);
		CUnifiedNetwork::getInstance()->send("FS", msgout);
	}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:27,代码来源:main.cpp

示例3: find

/*
 * Supports any service id, even one not added before (ignored then)
 */
void CTickProxy::removeService( TServiceId serviceId )
{
	vector<TServiceId>::iterator it = find( _Services.begin(), _Services.end(), serviceId );
	if ( it == _Services.end() )
		return; // ignore a service not registered
	
	_Services.erase( it );

	// Simulate Tock from leaving service if needed
	if ( State == ExpectingLocalTocks )
	{
		if ( find( _TockedServices.begin(), _TockedServices.end(), serviceId ) != _TockedServices.end() )
		{
			// The service already tocked and we are still in this state, it means we're waiting for another service to tock
			nlassert( _NbTocked != 0 );
			--_NbTocked; // decrement because _Service.size() is being decremented

			// If other tocks are coming, they will call doNextTask. However, it is possible that no
			// other tock is expected, if the tock did not triggered a master tock (changing State).
			if ( _NbTocked == _Services.size() )
				cbDoNextTask();
			else
				nldebug( "TCK- Service %hu already tocked, waiting for %u other tocks", serviceId.get(), _Services.size() - _NbTocked );
		}
		else
		{
			// The service didn't tock yet, interpret its quitting as a tock
			cbDoNextTask();
		}
	}
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:34,代码来源:tick_proxy.cpp

示例4: cbFESNbPlayers2

// This function is called by FES to setup the right number of players (if FES was already present before WS launching)
void	cbFESNbPlayers2(CMessage &msgin, const std::string &serviceName, TServiceId  sid)
{
	uint32	nbPlayers;
	uint32	nbPendingPlayers;
	msgin.serial(nbPlayers);
	msgin.serial(nbPendingPlayers);

	uint32 totalNbOnlineUsers = 0, totalNbPendingUsers = 0;
	for (list<CFES>::iterator it = FESList.begin(); it != FESList.end(); it++)
	{
		CFES &fes = *it;
		if (fes.SId == sid)
		{
			nldebug("Frontend '%d' reported %d online users", sid.get(), nbPlayers);
			fes.NbUser = nbPlayers;
			fes.NbPendingUsers = nbPendingPlayers;
			if (nbPlayers != 0 && fes.State == PatchOnly)
			{
				nlwarning("Frontend %d is in state PatchOnly, yet reports to have online %d players, state AcceptClientOnly is forced (FS_ACCEPT message sent)");
				(*it).setToAcceptClients();
			}
		}
		totalNbOnlineUsers += fes.NbUser;
		totalNbPendingUsers += fes.NbPendingUsers;
	}

	if (CWelcomeServiceMod::isInitialized())
		CWelcomeServiceMod::getInstance()->updateConnectedPlayerCount(totalNbOnlineUsers, totalNbPendingUsers);
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:30,代码来源:ryzom_welcome_service.cpp

示例5: cbFESNbPlayers

// This function is called by FES to setup the right number of players (if FES was already present before WS launching)
void	cbFESNbPlayers(CMessage &msgin, const std::string &serviceName, TServiceId  sid)
{
	// *********** WARNING *******************
	// This version of the callback is deprecated, the system
	// now use cbFESNbPlayers2 that report the pending user count
	// as well as the number of connected players.
	// It is kept for backward compatibility only.
	// ***************************************

	uint32	nbPlayers;
	msgin.serial(nbPlayers);

	uint32 totalNbOnlineUsers = 0, totalNbPendingUsers = 0;
	for (list<CFES>::iterator it = FESList.begin(); it != FESList.end(); it++)
	{
		if ((*it).SId == sid)
		{
			nldebug("Frontend '%d' reported %d online users", sid.get(), nbPlayers);
			(*it).NbUser = nbPlayers;
			if (nbPlayers != 0 && (*it).State == PatchOnly)
			{
				nlwarning("Frontend %d is in state PatchOnly, yet reports to have online %d players, state AcceptClientOnly is forced (FS_ACCEPT message sent)");
				(*it).setToAcceptClients();
			}
		}
		totalNbOnlineUsers += (*it).NbUser;
		totalNbPendingUsers += (*it).NbPendingUsers;
	}

	if (CWelcomeServiceMod::isInitialized())
		CWelcomeServiceMod::getInstance()->updateConnectedPlayerCount(totalNbOnlineUsers, totalNbPendingUsers);
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:33,代码来源:ryzom_welcome_service.cpp

示例6: cbFESRemovedPendingCookie

// This function is called when a FES rejected a client' cookie
void	cbFESRemovedPendingCookie(CMessage &msgin, const std::string &serviceName, TServiceId  sid)
{
	CLoginCookie	cookie;
	msgin.serial(cookie);
	nldebug( "ERLOG: RPC recvd from %s-%hu => %s removed", serviceName.c_str(), sid.get(), cookie.toString().c_str(), cookie.toString().c_str());


	// client' cookie rejected, no longer pending
	uint32 totalNbOnlineUsers = 0, totalNbPendingUsers = 0;
	for (list<CFES>::iterator it = FESList.begin(); it != FESList.end(); it++)
	{
		if ((*it).SId == sid)
		{
			if ((*it).NbPendingUsers > 0)
				--(*it).NbPendingUsers;
		}
		totalNbOnlineUsers += (*it).NbUser;
		totalNbPendingUsers += (*it).NbPendingUsers;
	}

	if (CWelcomeServiceMod::isInitialized())
	{
		CWelcomeServiceMod::getInstance()->pendingUserLost(cookie);
		CWelcomeServiceMod::getInstance()->updateConnectedPlayerCount(totalNbOnlineUsers, totalNbPendingUsers);
	}
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:27,代码来源:ryzom_welcome_service.cpp

示例7: cbCollisionServiceUp

	/****************************************************************************
	 * Connection callback for the collision service
	 ****************************************************************************/
	static void cbCollisionServiceUp(const std::string &serviceName, TServiceId sid, void *arg)
	{
		nldebug("SB: Collision Service UP, %s %s", serviceName.c_str(), sid.toString().c_str());
		clear();
		msgRegister(sid);
		for (_pmap::iterator it = playerList.begin(); it != playerList.end(); it++)
			addEntity(it->second.id, it->second.position, 1.0f);
	}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:11,代码来源:main.cpp

示例8: serviceConnection

void serviceConnection(const std::string &serviceName, TServiceId sid, void *arg)
{
	// don't add AS
	if (serviceName == "AS")
		return;

	if (sid.get() >= Services.size())
	{
		Services.resize(sid.get()+1);
	}

	Services[sid.get()].init(serviceName, sid);

	sendInformation(sid);

	nlinfo("%s-%hu connected", Services[sid.get()].ShortName.c_str(), Services[sid.get()].ServiceId.get());

}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:18,代码来源:admin_executor_service.cpp

示例9: cbFESDisconnection

// a front end closes the connection, deconnect him
void cbFESDisconnection (const std::string &serviceName, TServiceId  sid, void *arg)
{
	nldebug("new FES disconnection: sid %u", sid.get());

	for (list<CFES>::iterator it = FESList.begin(); it != FESList.end(); it++)
	{
		if ((*it).SId == sid)
		{
			// send a message to the LS to say that all players from this FES are offline
			map<uint32, TServiceId>::iterator itc = UserIdSockAssociations.begin();
			map<uint32, TServiceId>::iterator nitc = itc;
			while (itc != UserIdSockAssociations.end())
			{
				nitc++;
				if ((*itc).second == sid)
				{
					// bye bye little player
					uint32 userid = (*itc).first;
					nlinfo ("Due to a frontend crash, removed the player %d", userid);
					if (!DontUseLS)
					{
						CMessage msgout ("CC");
						msgout.serial (userid);
						uint8 con = 0;
						msgout.serial (con);
						CUnifiedNetwork::getInstance()->send ("LS", msgout);
					}
					UserIdSockAssociations.erase (itc);
				}
				itc = nitc;
			}

			bool	dummy;
			(*it).reportStateToLS(dummy, false);

			// remove the FES
			FESList.erase (it);

			break;
		}
	}

	// Update the welcome service client with the new count of connection

	uint32 totalNbOnlineUsers =0, totalNbPendingUsers = 0;
	for (list<CFES>::iterator it = FESList.begin(); it != FESList.end(); it++)
	{
		const CFES &fes = *it;
		totalNbOnlineUsers += fes.NbUser;
		totalNbPendingUsers += fes.NbPendingUsers;
	}

	if (CWelcomeServiceMod::isInitialized())
		CWelcomeServiceMod::getInstance()->updateConnectedPlayerCount(totalNbOnlineUsers, totalNbPendingUsers);

	displayFES ();
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:58,代码来源:ryzom_welcome_service.cpp

示例10: cbUpService

void cbUpService(const std::string &serviceName, TServiceId sid, void *arg)
{
	nlinfo("Service %s %d is up", serviceName.c_str(), sid.get());

	CMessage msgout("TOTO");
	uint32 i = 10;
	msgout.serial(i);
	CUnifiedNetwork::getInstance()->send(sid, msgout);
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:9,代码来源:gpm_service.cpp

示例11: cbFESConnection

// a new front end connecting to me, add it
void cbFESConnection (const std::string &serviceName, TServiceId  sid, void *arg)
{
	FESList.push_back (CFES ((TServiceId)sid));
	nldebug("new FES connection: sid %u", sid.get());
	displayFES ();

	bool	dummy;
	FESList.back().reportStateToLS(dummy);

	if (!UsePatchMode.get())
	{
		FESList.back().setToAcceptClients();
	}
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:15,代码来源:ryzom_welcome_service.cpp

示例12: cbLSChooseShard

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// CONNECTION TO THE LOGIN SERVICE ///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void cbLSChooseShard (CMessage &msgin, const std::string &serviceName, TServiceId  sid)
{
	// the LS warns me that a new client want to come in my shard

	nldebug( "ERLOG: CS recvd from %s-%hu", serviceName.c_str(), sid.get());

	//
	// S07: receive the "CS" message from LS and send the "CS" message to the selected FES
	//

	CLoginCookie cookie;
	msgin.serial (cookie);
	string userName, userPriv, userExtended;
	msgin.serial (userName);

	try
	{
		msgin.serial (userPriv);
	}
	catch (const Exception &)
	{
		nlwarning ("LS didn't give me the user privilege for user '%s', set to empty", userName.c_str());
	}

	try
	{
		msgin.serial (userExtended);
	}
	catch (const Exception &)
	{
		nlwarning ("LS didn't give me the extended data for user '%s', set to empty", userName.c_str());
	}


	string ret = lsChooseShard(userName, cookie, userPriv, userExtended, WS::TUserRole::ur_player, 0xffffffff, ~0);

	if (!ret.empty())
	{
		// send back an error message to LS
		CMessage msgout ("SCS");
		msgout.serial (ret);
		msgout.serial (cookie);
		CUnifiedNetwork::getInstance()->send(sid, msgout);
	}
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:50,代码来源:ryzom_welcome_service.cpp

示例13: cbServiceReady

static void cbServiceReady(CMessage &msgin, const std::string &serviceName, TServiceId sid)
{
	if (sid.get() >= Services.size())
	{
		nlwarning("Ready of an unknown service %s-%hu", serviceName.c_str(), sid.get());
		return;
	}

	if (!Services[sid.get()].Connected)
	{
		nlwarning("Ready of an unknown service %s-%hu", serviceName.c_str(), sid.get());
		return;
	}

	nlinfo("*:*:%d is ready '%s'", Services[sid.get()].ServiceId.get(), Services[sid.get()].getServiceUnifiedName().c_str());
	Services[sid.get()].Ready = true;
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:17,代码来源:admin_executor_service.cpp

示例14: cbExecCommandResult

static void cbExecCommandResult(CMessage &msgin, const std::string &serviceName, TServiceId sid)
{
	// treat the rely message sent back from a service whom we asked to execute a command
	NLMISC::InfoLog->displayNL("EXEC_COMMAND_RESULT' Received from: %3d: %s", sid.get() ,serviceName.c_str());

	// retrieve the text from the input message
	CSString txt;
	msgin.serial(txt);

	// divide the text into lines because NeL doesn't like long texts
	CVectorSString lines;
	txt.splitLines(lines);

	// display the lines of text
	for (uint32 i=0;i<lines.size();++i)
	{
		NLMISC::InfoLog->displayNL("%s",lines[i].c_str());
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:19,代码来源:dynamic_scenario_service.cpp

示例15: writeServiceLaunchCtrl

bool writeServiceLaunchCtrl(TServiceId serviceId,bool delay,const std::string& txt)
{
	// run trough the services container looking for a match for the service id that we've been given
	for (TServices::iterator it= Services.begin(); it!=Services.end(); ++it)
	{
		if (it->ServiceId==serviceId)
		{
			// we found a match for the service id so try to do something sensible with it...

			// get hold of the different components of the command description...
			string alias, command, path, arg;
			bool ok= getServiceLaunchInfo(it->AliasName,alias,command,path,arg);
			if (!ok) return false;

			// go ahead and write the launch ctrl file...
			return writeServiceLaunchCtrl(alias,path,delay,txt);
		}
	}

	// we failed to find a match for the serviceId that we've been given so complain and return false
	nlwarning("Failed to write launch_ctrl file for unknown service: %u",serviceId.get());
	return false;
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:23,代码来源:admin_executor_service.cpp


注:本文中的TServiceId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。