Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetHost.h
Show All 12 Lines | |||||
* | * | ||||
* 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 NETHOST_H | #ifndef NETHOST_H | ||||
#define NETHOST_H | #define NETHOST_H | ||||
#include "NetMessages.h" | |||||
leper: No need to move that include, just forward declare CNetMessageBuffer, which is passed by… | |||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include <map> | #include <map> | ||||
/** | /** | ||||
* @file | * @file | ||||
* Various declarations shared by networking code. | * Various declarations shared by networking code. | ||||
*/ | */ | ||||
typedef struct _ENetPeer ENetPeer; | typedef struct _ENetPeer ENetPeer; | ||||
typedef struct _ENetPacket ENetPacket; | typedef struct _ENetPacket ENetPacket; | ||||
typedef struct _ENetHost ENetHost; | typedef struct _ENetHost ENetHost; | ||||
class CNetMessage; | |||||
struct PlayerAssignment | struct PlayerAssignment | ||||
{ | { | ||||
/** | /** | ||||
* Whether the player is currently connected and active. | * Whether the player is currently connected and active. | ||||
* (We retain information on disconnected players to support rejoining, | * (We retain information on disconnected players to support rejoining, | ||||
* but don't transmit these to other clients.) | * but don't transmit these to other clients.) | ||||
*/ | */ | ||||
Show All 36 Lines | public: | ||||
/** | /** | ||||
* Transmit a message to the given peer. | * Transmit a message to the given peer. | ||||
* @param message message to send | * @param message message to send | ||||
* @param peer peer to send to | * @param peer peer to send to | ||||
* @param peerName name of peer for debug logs | * @param peerName name of peer for debug logs | ||||
* @return true on success, false on failure | * @return true on success, false on failure | ||||
*/ | */ | ||||
static bool SendMessage(const CNetMessage* message, ENetPeer* peer, const char* peerName); | static bool SendMessage(const CNetMessageBuffer& message, ENetPeer* peer, const char* peerName); | ||||
/** | /** | ||||
* Construct an ENet packet by serialising the given message. | * Construct an ENet packet from the given message. | ||||
* @return NULL on failure | * @return NULL on failure | ||||
*/ | */ | ||||
static ENetPacket* CreatePacket(const CNetMessage* message); | static ENetPacket* CreatePacket(const CNetMessageBuffer& message); | ||||
/** | /** | ||||
* Initialize ENet. | * Initialize ENet. | ||||
* This must be called before any other networking code. | * This must be called before any other networking code. | ||||
*/ | */ | ||||
static void Initialize(); | static void Initialize(); | ||||
/** | /** | ||||
* Deinitialize ENet. | * Deinitialize ENet. | ||||
*/ | */ | ||||
static void Deinitialize(); | static void Deinitialize(); | ||||
}; | }; | ||||
#endif // NETHOST_H | #endif // NETHOST_H |
Wildfire Games · Phabricator
No need to move that include, just forward declare CNetMessageBuffer, which is passed by reference everywhere in here.