Esempio n. 1
0
void SessionManager::HandleReqLogin(std::shared_ptr<RawMessage> spMsg)
{
    CHECK_NULL_ASSERT(spMsg);
    ReqLogin req;
    req.ParseFromString(spMsg->strmsg());
    UserData data;

    data.set_id(spMsg->clientid());   // 使用连接id
    data.set_name(req.username());

    DEBUG_LOG("收到了登陆请求!");
    DEBUG_LOG(req.username());

    auto spUser = ServerBase::GetInstance()->GetUserMgr()->CreateUser(data);
    spUser->SetConnId(spMsg->clientid());

    NotifyLoginResult notify;
    notify.set_result(NLR_SUCCESS);

    NetApi::SendPacketToUser(spUser, notify);
}