void RankingClientImpl::parseEvent(const CL_NetGameEvent &p_event) { const CL_String eventName = p_event.get_name(); if (eventName == EVENT_RANKING_ENTRIES) { parseEntriesEvent(p_event); } else { cl_log_event(LOG_ERROR, "event remains unhandled: %1", p_event.to_string()); } }
void RaceStart::parseEvent(const CL_NetGameEvent &p_event) { assert(p_event.get_name() == EVENT_RACE_START); int i = 0; m_carPosition.x = static_cast<float> (p_event.get_argument(i++)); m_carPosition.y = static_cast<float> (p_event.get_argument(i++)); m_carRotation.set_radians(static_cast<float> (p_event.get_argument(i++))); }
void CarState::parseEvent(const CL_NetGameEvent &p_event) { assert(p_event.get_name() == EVENT_CAR_STATE); m_name = p_event.get_argument(0); m_serialData = CL_NetGameEvent(""); const int argCount = static_cast<signed>(p_event.get_argument_count()); for (int i = 1; i < argCount; ++i) { m_serialData.add_argument(p_event.get_argument(i)); } }
void ServerImpl::handleEvent(CL_NetGameConnection *p_conn, const CL_NetGameEvent &p_event) { try { bool unhandled = false; const CL_String eventName = p_event.get_name(); // connection initialize events if (eventName == EVENT_CLIENT_INFO) { onClientInfo(p_conn, p_event); } // master server events if (eventName == EVENT_INFO_REQUEST) { onServerInfoRequest(p_conn, p_event); } // race events else if (eventName == EVENT_CAR_STATE) { onCarState(p_conn, p_event); } else if (eventName == EVENT_VOTE_START) { onVoteStart(p_conn, p_event); } else if (eventName == EVENT_VOTE_TICK) { onVoteTick(p_conn, p_event); } // unknown events remains unhandled else { unhandled = true; } if (unhandled) { cl_log_event( LOG_EVENT, "event %1 remains unhandled", p_event.to_string() ); } } catch (CL_Exception e) { cl_log_event(LOG_ERROR, e.message); } }
void Goodbye::parseEvent(const CL_NetGameEvent &p_event) { assert(p_event.get_name() == EVENT_GOODBYE); m_reason = static_cast<GoodbyeReason>(static_cast<int>(p_event.get_argument(0))); }