#include "client.h"
Include dependency graph for message.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | MsgDescr_t |
Describes a message, including who should receive it and data needed to handle acknowledgments. More... | |
struct | NetBuffer_t |
The buffer type used to store messages sent and received over the network. More... | |
Defines | |
#define | DESTMAPLEN bitarraylen(MAX_PLAYERS, DESTMAPTYPE) |
The number of elements in the array MsgDescr::destMap. | |
#define | DESTMAPTYPE Uint16 |
The data type used for MsgDescr::destMap. | |
#define | GetDestMapFlag(id) bitflag(id, DESTMAPTYPE) |
Returns the bit flag that indicates the given client in the MsgDescr::destMap array at the correct index (see GetDestMapIndex()). | |
#define | GetDestMapIndex(id) bitindex(id, DESTMAPTYPE) |
Returns the index to the MsgDescr::destMap array that contains the flag for the given client. | |
#define | MSG_MAX_SIZE 510 |
The maximum size of a message in bytes. | |
#define | SetDestToAll(msg) |
Marks a message as being destined to all clients. | |
Typedefs | |
typedef void(*) | AcknowledgeMsg (MsgDescr *descr, int cid) |
The function prototype used to react to the recipient acknowledging a message. | |
typedef Bool(*) | ApproveSendMsg (MsgDescr *descr, int cid) |
Approves sending a message to a given recipient. | |
typedef void(*) | ConstructMsg (MsgDescr *descr) |
The function prototype used to construct the message in a buffer. | |
typedef void(*) | FailMsg (MsgDescr *descr, ClientData *client) |
The function prototype used to react to a recipient that did not acknowledge a message, or if an error occured when trying to send a message. | |
typedef Bool(*) | HandleMsg (SocketAddr *origin, NetBuffer *buffer, Uint8 *clientId, Uint16 messageId) |
The function prototype used to process incomming messages. | |
typedef MsgDescr_t | MsgDescr |
typedef NetBuffer_t | NetBuffer |
Enumerations | |
enum | { MSG_TYPE_ACK, MSG_TYPE_CONN_REQ, MSG_TYPE_CONN_DENY, MSG_TYPE_CONN_ACCEPT, MSG_TYPE_CONN_DISCONN, MSG_TYPE_OPTION, MSG_TYPE_OBSTACLE, MSG_TYPE_SPAWN, MSG_TYPE_GOAL, MSG_TYPE_GAME_START, MSG_TYPE_GAME_OVER, MSG_TYPE_SCORE = MSG_TYPE_GOAL + 1, MSG_TYPE_PLAYER_UPDATE, MSG_TYPE_PLAYER_SPWAN, MSG_TYPE_MAX } |
The message type identifiers that are always sent as the first byte of every message. More... | |
Functions | |
Bool | AddMessage (MsgDescr *msg) |
Adds a new message to the messaging system and sends it out immediately. | |
void | BufferFree (NetBuffer *buff) |
Returns a no longer used network buffer to the queue of available buffers. | |
NetBuffer * | BufferNew () |
Obtains a new message buffer from the internal list of buffers. | |
void | BufferVecDestr (void *buff) |
A Vector destructor that returns a no longer used network buffer to the queue of available buffers. | |
void | CancelAllMessages () |
Cancels all in-flight messages effectively killing communication with the remote end(s). | |
int | GetNumOutgoingMessages () |
Returns the number of messages that have been sent but not acknowledged. | |
void | MessageFree (MsgDescr *msg) |
Returns an unused message to the queue of available messages, or deallocates it if the maximum number of messages are in the available queue (MAX_MESSAGES). | |
Bool | MessageInit () |
Initializes the network messaging system. | |
MsgDescr * | MessageNew () |
Gets a new uninitialized message so that it can be put to use describing a new message. | |
void | MessageUninit () |
Uninitializes the network messaging system. | |
void | MsgFailDisconnect (MsgDescr *descr, ClientData *client) |
A message failure function that disconnects from the remote end in the most reliable manner possible. | |
void | MsgFailDropConnection (MsgDescr *descr, ClientData *client) |
A message failure function that immediately terminates all communication. | |
void | ProcessNetworkMessages () |
Handles all network I/O for the client or server. | |
Bool | ReceiveMessages () |
Handles all incomming messages. | |
Bool | SendDisconnectMessage (Uint8 id) |
Sends a disconnect message (see MSG_TYPE_CONN_DISCONN and the data format) indicating the specified client is leaving the game. | |
void | ServiceMessages () |
Services the outgoing messages that are already in the system. | |
Bool | ValidateClient (SocketAddr *origin, Uint8 clientId) |
Determines if incomming client data came from a valid source. | |
Bool | ValidateServer (SocketAddr *origin) |
Determines if the inomming server data came from the server that is running the game, and if this process is a client. |
Copyright (C) 2007 Jeff Jackowski
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Or visit their website at: http://www.gnu.org/
Definition in file message.h.