Exemple #1
0
void CNetworkPlayer::SendError (const ErrorInfo & error) {
    Command command;
    command.set_type(Command::NotifyError);
    NotifyError * notifyError = command.MutableExtension(NotifyError::notifyError);
    *(notifyError->mutable_errorinfo()) = error;
    SendReliableCommand(command);
}
Exemple #2
0
void CNetworkPlayer::HandleCommand (const Command & command) {
    if (!m_authenticated) {
        if (command.type() == Command::ConnectRequest) {
            Command out;
            out.set_type(Command::ConnectResponse);
            ConnectResponse * response = out.MutableExtension(ConnectResponse::connectResponse);
            *response->mutable_errorinfo() = ERR(ErrorInfo::OK);
            response->set_playerid(m_playerId);
            SendReliableCommand(out);
            m_authenticated = true;
            for (auto notify : m_notifies) {
                notify->OnNetworkPlayerAuthenticated(this);
            }
        }
        else {
            SendError(ERR(ErrorInfo::NotConnected));
        }
    }
    else {
        for (auto notify : m_notifies) {
            notify->OnNetworkPlayerCommand(this, command);
        }
    }
}