本文整理汇总了C++中DataModel::FindService方法的典型用法代码示例。如果您正苦于以下问题:C++ DataModel::FindService方法的具体用法?C++ DataModel::FindService怎么用?C++ DataModel::FindService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel::FindService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Kick
/**
* Kicks the player from the server.
* @author John M. Harris, Jr.
*/
void Player::Kick(){
OpenBlox::OBGame* game = OpenBlox::OBGame::getInstance();
if(!game){ return; }
if(game->isServer()){
DataModel* dm = game->getDataModel();
if(dm){
Instance* nsi = dm->FindService("NetworkServer");
if(nsi){
NetworkPeer* ns = dynamic_cast<NetworkPeer*>(nsi);
if(ns){
std::vector<Instance*> nrs = ns->GetChildren();
for(std::vector<Instance*>::size_type i = 0; i != nrs.size(); i++){
Instance* kid = nrs[i];
if(kid){
if(NetworkReplicator* nr = dynamic_cast<NetworkReplicator*>(kid)){
if(nr->GetPlayer() == this){
RakNet::SystemAddress addr = nr->getAddress();
RakNet::RakPeerInterface* peer = ns->getPeer();
if(peer){
peer->CloseConnection(addr, true, 0, HIGH_PRIORITY);
}
}
}
}
}
}
}
}
}else{
DataModel* dm = game->getDataModel();
if(dm){
Instance* plrsi = dm->FindService("Players");
if(plrsi){
if(Players* plrs = dynamic_cast<Players*>(plrsi)){
if(plrs->getLocalPlayer() == this){
Instance* nci = dm->FindService("NetworkClient");
if(nci){
if(NetworkClient* nc = dynamic_cast<NetworkClient*>(nci)){
nc->Disconnect();
}
}
return;
}
}
}
}
WLOG("Attempt to kick a player from client.");
}
}