您的位置:首页 > 其它

RakNet 服务器设置密码 & 客户端使用密码 访问

2013-12-15 22:30 232 查看
游戏的服务器怎么能没有密码……

RakNet服务端设置密码:

if (m_pRakpeerInterface==nullptr)
{
std::cout<<"(server) m_pRakpeerInterface is null"<<std::endl;;
}

m_pRakpeerInterface->SetIncomingPassword(passwdStr.c_str(),passwdStr.length());

//start
m_pRakpeerInterface->Startup(MAX_CLIENTS,&RakNet::SocketDescriptor(SERVER_PORT,0),1);
m_pRakpeerInterface->SetMaximumIncomingConnections(MAX_CLIENTS);


RakNet客户端使用密码访问:

//start raknet network connect
if (m_pRakpeerInterface==nullptr)
{
std::cout<<"(client) m_pRakpeerInterface is null"<<std::endl;;
}
//startup
m_pRakpeerInterface->Startup(1,&RakNet::SocketDescriptor(SERVER_PORT,0),1);

RakNet::ConnectionAttemptResult res= m_pRakpeerInterface->Connect(ipAddrStr.c_str(), SERVER_PORT, passwdStr.c_str(), passwdStr.length());
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐