本文整理汇总了C++中raknet::SystemAddress::SetBinaryAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ SystemAddress::SetBinaryAddress方法的具体用法?C++ SystemAddress::SetBinaryAddress怎么用?C++ SystemAddress::SetBinaryAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::SystemAddress
的用法示例。
在下文中一共展示了SystemAddress::SetBinaryAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processDatabasePlayer
//------------------------------------------------------------------------------------
void PlayerManager::processDatabasePlayer(NetPack* pPack)
{
///把数据转发给客户端
Tag_PlayerCollect* players=static_cast<Tag_PlayerCollect*>(pPack->getData());
if(players->m_Count==0)///表示这个帐号还没有新建角色
{
}else ///把所有角色发给客户端
{
}
RakNet::SystemAddress address;
address.SetBinaryAddress(players->m_ip);
NetWorkServer::getSingleton().send(GM_REQUEST_PLAYERS,(const char*)pPack->getData(),pPack->getDataLength(),address);
return ;
}
示例2: OnSend
void SimulateClientMainFrame::OnSend( wxCommandEvent& event )
{
wxString serverName=m_serverList->GetStringSelection();
wxString messageID=m_messagelist->GetStringSelection();
wxString message= m_MessageText->GetValue();
//if(serverName.empty()||messageID.empty()||messageID.empty())
//{
// wxMessageBox("请选择服务器,消息id,和消息内容");
// return ;
//}
unsigned int id=stringToMessageID(messageID.c_str());
RakNet::SystemAddress address;
address.SetBinaryAddress(serverName.c_str());
if(id==GM_TEXT_MESSAGE)
{
NetWorkClient::getSingletonPtr()->getConnectInstance("statserver")->send(id,message.c_str(),message.Length()+1);
m_MessageText->Clear();
addSendMessage(message);
}else if(GM_ACCOUNT_REQUEST==id)
{
UserLogin userlogin;
::ZeroMemory(&userlogin,sizeof(userlogin));
if(sscanf(message.c_str(),"%s = %s",userlogin.m_account,userlogin.m_password)>0)
{
NetWorkClient::getSingleton().getConnectInstance("statserver")->send(id,userlogin);
}else
{
wxMessageBox("格式不正确请用;分格开用户名和密码");
}
// memcpy(userlogin.m_account,"palyer1",strlen("player1"));
// memcpy(userlogin.m_password,"palyer1",strlen("player1"));
}else if(id==GM_CHATMESSAGE)
{
NetWorkClient::getSingletonPtr()->getConnectInstance(GAMESERVER)->send(id,message.c_str(),message.Length()+1);
m_MessageText->Clear();
addSendMessage(message);
}else if(id==GM_CONNECT_GAMESERVER)
{
///发送帐号id组游戏逻辑服务器
long accountid=0;
if(message.ToLong(&accountid))
{
UINT temid=accountid;
NetWorkClient::getSingletonPtr()->getConnectInstance(GAMESERVER)->send(id,temid);
m_MessageText->Clear();
}
}
return ;
}
示例3: update
//.........这里部分代码省略.........
//Find a session index for the player
{
char buf[4096];
buf[0] = ID_SETTINGS;
memcpy(buf+1,&secondsBetweenSync,sizeof(int));
strcpy(buf+1+sizeof(int),username.c_str());
rakInterface->Send(
buf,
1+sizeof(int)+username.length()+1,
HIGH_PRIORITY,
RELIABLE_ORDERED,
ORDERING_CHANNEL_SYNC,
p->guid,
false
);
}
if(acceptedPeers.size()>=maxPeerID-1)
{
//Sorry, no room
rakInterface->CloseConnection(p->systemAddress,true);
}
else if(acceptedPeers.size())
{
printf("Asking other peers to accept %s\n",p->systemAddress.ToString());
waitingForAcceptFrom[p->systemAddress] = std::vector<RakNet::RakNetGUID>();
for(int a=0; a<acceptedPeers.size(); a++)
{
RakNet::RakNetGUID guid = acceptedPeers[a];
waitingForAcceptFrom[p->systemAddress].push_back(guid);
cout << "SENDING ADVERTIZE TO " << guid.ToString() << endl;
char buf[4096];
buf[0] = ID_ADVERTISE_SYSTEM;
strcpy(buf+1,p->systemAddress.ToString(true));
rakInterface->Send(buf,1+strlen(p->systemAddress.ToString(true))+1,HIGH_PRIORITY,RELIABLE_ORDERED,ORDERING_CHANNEL_SYNC,guid,false);
}
printf("Asking other peers to accept\n");
}
else
{
//First client, automatically accept
acceptPeer(p->systemAddress,machine);
}
break;
case ID_INCOMPATIBLE_PROTOCOL_VERSION:
printf("ID_INCOMPATIBLE_PROTOCOL_VERSION\n");
break;
case ID_ACCEPT_NEW_HOST:
{
printf("Accepting new host\n");
RakNet::SystemAddress saToAccept;
saToAccept.SetBinaryAddress(((char*)p->data)+1);
for(int a=0; a<waitingForAcceptFrom[saToAccept].size(); a++)
{
if(waitingForAcceptFrom[saToAccept][a]==p->guid)
{
waitingForAcceptFrom[saToAccept].erase(waitingForAcceptFrom[saToAccept].begin()+a);
break;
}
}
if(waitingForAcceptFrom[saToAccept].empty())
{
cout << "Accepting: " << saToAccept.ToString() << endl;
waitingForAcceptFrom.erase(waitingForAcceptFrom.find(saToAccept));
acceptPeer(saToAccept,machine);
}
}
break;
case ID_REJECT_NEW_HOST:
{
RakNet::SystemAddress saToReject;
saToReject.SetBinaryAddress(((char*)p->data)+1);
printf("Rejecting new client\n");
cout << p->guid.ToString() << " REJECTS " << saToReject.ToString() << endl;
if(waitingForAcceptFrom.find(saToReject)==waitingForAcceptFrom.end())
printf("Could not find waitingForAcceptFrom for this GUID, weird");
else
waitingForAcceptFrom.erase(waitingForAcceptFrom.find(saToReject));
rakInterface->CloseConnection(saToReject,true);
}
break;
case ID_CLIENT_INPUTS:
if(peerIDs.find(p->guid)==peerIDs.end() || peerInputs.find(peerIDs[p->guid])==peerInputs.end())
{
cout << __FILE__ << ":" << __LINE__ << " OOPS!!!!\n";
}
//cout << "GOT CLIENT INPUTS\n";
peerInputs[peerIDs[p->guid]].push_back(string((char*)GetPacketData(p),(int)GetPacketSize(p)));
break;
default:
printf("UNEXPECTED PACKET ID: %d\n",int(packetIdentifier));
break;
}
}
}