代码拉取完成,页面将自动刷新
同步操作将从 留天下/CM-Server 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "logictalk.h"
#include"networkmanager.h"
#include"messageconst.h"
DEFINE_SINGLE_ATTRIBUTES(LogicTalk);
LogicTalk::LogicTalk()
{
NET_INSTANCE()->add(MESSAGE_WORLD_TALK,handler(this,SEL_EVENTFUNC(LogicTalk::c2sWorldTalk)));
NET_INSTANCE()->add(MESSAGE_PRIVATE_TALK,handler(this,SEL_EVENTFUNC(LogicTalk::c2sPrivateTalk)));
}
void LogicTalk::c2sWorldTalk(Json::Value& msg)
{
cout<<"LogicTalk::c2sWorldTalk"<<msg.toStyledString()<<endl;
int fd=NET_INSTANCE()->getFd();
auto& playermaps= NET_SOCKET().m_playermaps;
cout<<playermaps[fd].rolename<<" in the world say: "<<msg["msg"].asString()<<endl;
msg["fd"]=fd;
for(auto var:playermaps)
{
if(var.first==fd)
msg["fd"]=-1;
NET_INSTANCE()->send(var.first,MESSAGE_WORLD_TALK,msg);
//write(var.first,(char*)msg,sizeof(WorldTalk_Msg));
}
}
void LogicTalk::c2sPrivateTalk(Json::Value& msg)
{
int fd=NET_INSTANCE()->getFd();
auto& playermaps= NET_SOCKET().m_playermaps;
int dest=msg["dest"].asInt();
if(playermaps.find(dest)!=playermaps.end())
{
msg["fd"]=fd;
cout<<playermaps[fd].rolename<<" say "<<msg["msg"].asString()<<" to "<<playermaps[dest].rolename<<endl;
NET_INSTANCE()->send(dest,MESSAGE_PRIVATE_TALK,msg);
//write(msg->dest,(char*)msg,sizeof(PrivateTalk_Msg));
}
msg["fd"]=-1;
NET_INSTANCE()->send(fd,MESSAGE_PRIVATE_TALK,msg);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。