Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetClient.h
/* Copyright (C) 2022 Wildfire Games. | /* Copyright (C) 2023 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
* GNU General Public License for more details. | * GNU General Public License for more details. | ||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#ifndef NETCLIENT_H | #ifndef NETCLIENT_H | ||||
#define NETCLIENT_H | #define NETCLIENT_H | ||||
#include "network/FSM.h" | #include "network/FSM.h" | ||||
#include "network/NetFileTransfer.h" | #include "network/NetFileTransfer.h" | ||||
#include "network/NetHost.h" | #include "network/NetHost.h" | ||||
#include "network/NetModerationTables.h" | |||||
#include "network/NetMessage.h" | |||||
#include "scriptinterface/Object.h" | #include "scriptinterface/Object.h" | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include <ctime> | #include <ctime> | ||||
#include <deque> | #include <deque> | ||||
#include <thread> | #include <thread> | ||||
▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | public: | ||||
void SendRejoinedMessage(); | void SendRejoinedMessage(); | ||||
/** | /** | ||||
* Call to kick/ban a client | * Call to kick/ban a client | ||||
*/ | */ | ||||
void SendKickPlayerMessage(const CStrW& playerName, bool ban); | void SendKickPlayerMessage(const CStrW& playerName, bool ban); | ||||
/** | /** | ||||
* Check and send a moderation message to kick, mute, ban, etc. a client | |||||
*/ | |||||
void SendModerationMessage(CNetMessage *message); | |||||
/** | |||||
* Fill a CModerationMessage with the field data in the arguments. Does not affect the list of identifiers | |||||
* See CNetServerWorker::AddFieldsToModerationMessage() for the parameter documentation | |||||
*/ | |||||
static void AddFieldsToModerationMessage(CNetMessage* message, const u8 action, const u8 actionIsCommand, const u8 responseType, const u8 responseCode, const u8 effectType); | |||||
/** | |||||
* Add a single identifier to the end of the list of identifiers in a CModerationMessage. | |||||
* See CNetServerWorker::AddFieldsToModerationMessage() for the parameter documentation | |||||
*/ | |||||
static void AddIdentifierToModerationMessage(CNetMessage* message, const u8 identifierType, const CStrW& identifier); | |||||
/** | |||||
* Fill a CModerationMessage with the default field data and empty identifiers list | |||||
*/ | |||||
static void ResetModerationMessage(CNetMessage* message); | |||||
/** | |||||
* Notify the GUI of a received moderation response so that it can be decoded | |||||
* and notification of the results can be made to the user | |||||
*/ | |||||
void PostModerationResponseToScript(CNetMessage* message); | |||||
/** | |||||
* Call when the client has paused or unpaused the game. | * Call when the client has paused or unpaused the game. | ||||
*/ | */ | ||||
void SendPausedMessage(bool pause); | void SendPausedMessage(bool pause); | ||||
/** | /** | ||||
* @return Whether the NetClient is shutting down. | * @return Whether the NetClient is shutting down. | ||||
*/ | */ | ||||
bool ShouldShutdown() const; | bool ShouldShutdown() const; | ||||
Show All 17 Lines | private: | ||||
static bool OnGameSetup(void* context, CFsmEvent* event); | static bool OnGameSetup(void* context, CFsmEvent* event); | ||||
static bool OnPlayerAssignment(void* context, CFsmEvent* event); | static bool OnPlayerAssignment(void* context, CFsmEvent* event); | ||||
static bool OnInGame(void* context, CFsmEvent* event); | static bool OnInGame(void* context, CFsmEvent* event); | ||||
static bool OnGameStart(void* context, CFsmEvent* event); | static bool OnGameStart(void* context, CFsmEvent* event); | ||||
static bool OnJoinSyncStart(void* context, CFsmEvent* event); | static bool OnJoinSyncStart(void* context, CFsmEvent* event); | ||||
static bool OnJoinSyncEndCommandBatch(void* context, CFsmEvent* event); | static bool OnJoinSyncEndCommandBatch(void* context, CFsmEvent* event); | ||||
static bool OnRejoined(void* context, CFsmEvent* event); | static bool OnRejoined(void* context, CFsmEvent* event); | ||||
static bool OnKicked(void* context, CFsmEvent* event); | static bool OnKicked(void* context, CFsmEvent* event); | ||||
static bool OnModeration(void* context, CFsmEvent* event); | |||||
static bool OnClientTimeout(void* context, CFsmEvent* event); | static bool OnClientTimeout(void* context, CFsmEvent* event); | ||||
static bool OnClientPerformance(void* context, CFsmEvent* event); | static bool OnClientPerformance(void* context, CFsmEvent* event); | ||||
static bool OnClientsLoading(void* context, CFsmEvent* event); | static bool OnClientsLoading(void* context, CFsmEvent* event); | ||||
static bool OnClientPaused(void* context, CFsmEvent* event); | static bool OnClientPaused(void* context, CFsmEvent* event); | ||||
static bool OnLoadedGame(void* context, CFsmEvent* event); | static bool OnLoadedGame(void* context, CFsmEvent* event); | ||||
/** | /** | ||||
* Take ownership of a session object, and use it for all network communication. | * Take ownership of a session object, and use it for all network communication. | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator