NetworkMessage stores the serialized byte data of a single outbound network message, along with fields that specify how itreated by the network connection. More...
#include <NetworkMessage.h>
Inherits kNet::PoolAllocatable< NetworkMessage >.
Public Member Functions | |
| NetworkMessage () | |
| To create a NetworkMessage, call MessageConnection::StartNewMessage() instead of directly instantiating a message structure. | |
| void | Resize (size_t newBytes, bool discard=true) |
| Resizes the message to the given amount of bytes. | |
| bool | IsNewerThan (const NetworkMessage &rhs) const |
| Checks if this message is newer than the other message. | |
| int | GetTotalDatagramPackedSize () const |
| Returns the total number of bytes this datagram will take up space when it is serialized to an UDP channel. | |
| unsigned long | MessageNumber () const |
| Returns the number of this message. The message number identifies the admission order of messages to the outbound queue. | |
Public Attributes | |
| char * | data |
| Stores the actual data of the message. | |
| unsigned long | priority |
| The send priority of this message with respect to other messages. | |
| packet_id_t | id |
| The ID of this message. IDs 0 - 5 are reserved for the protocol and may not be used. | |
| unsigned long | contentID |
| When sending out a message, the application can attach a content ID to the message, which will effectively replace all the older messages with the same messageID and contentID. | |
| bool | reliable |
| If true, this message should be delivered reliably, possibly resent to guarantee that the receiving party gets it. | |
| bool | inOrder |
| If true, this message should be delivered in-order with all the other in-order messages. | |
| bool | obsolete |
| If this flag is set, the message will not be sent and will be deleted as soon as possible. | |
Static Public Attributes | |
| static const unsigned long | cPriorityDontSend = 0xFFFFFFFF |
| A message with this priority is obsolete and should not be sent through the connection. | |
| static const unsigned long | cMaxPriority = 0xFFFFFFFE |
| The maximum priority a message can have. | |
NetworkMessage stores the serialized byte data of a single outbound network message, along with fields that specify how itreated by the network connection.
| kNet::NetworkMessage::NetworkMessage | ( | ) |
To create a NetworkMessage, call MessageConnection::StartNewMessage() instead of directly instantiating a message structure.
This is because each MessageConnection implements an internal pool of NetworkMessage structures which are reused between messages, to avoid excessive dynamic memory allocation.
| void kNet::NetworkMessage::Resize | ( | size_t | newBytes, | |
| bool | discard = true | |||
| ) |
Resizes the message to the given amount of bytes.
Reallocates the data buffer if it cannot fit into the new size.
| newBytes | The new amount of bytes to use for the message. | |
| discard | If true, any existing partially filled data will not be copied over, but the new buffer will have its bytes left uninitialized. If false, this function preserves any old partially filled data and works like std::vector::resize(). The intended purpose of this function is to be called prior to filling in any data, and so the default value is true. |
References data.
Referenced by kNet::MessageConnection::HandleInboundMessage(), and kNet::MessageConnection::StartNewMessage().
| int kNet::NetworkMessage::GetTotalDatagramPackedSize | ( | ) | const |
Stores the actual data of the message.
When writing a new message, fill in the data bytes here. This buffer can hold Capacity() amount of bytes. If you need more, call Reallocate() with the desired amount of bytes. This field is read-only, do not change this pointer value.
Referenced by kNet::NetworkServer::BroadcastMessage(), kNet::MessageConnection::HandleInboundMessage(), kNet::MessageConnection::Process(), Resize(), kNet::MessageConnection::Send(), kNet::MessageConnection::SendMessage(), kNet::MessageConnection::SendStruct(), and kNet::MessageConnection::SplitAndQueueMessage().
| unsigned long kNet::NetworkMessage::priority |
The send priority of this message with respect to other messages.
Priority 0 is the lowest, and priority 0xFFFFFFFE is the highest. Priority 0xFFFFFFFF is a special one that means 'don't send this message'.
Referenced by kNet::NetworkServer::BroadcastMessage(), kNet::MessageConnection::Send(), kNet::MessageConnection::SendMessage(), kNet::MessageConnection::SendStruct(), kNet::MessageConnection::SplitAndQueueMessage(), and kNet::MessageConnection::StartNewMessage().
| unsigned long kNet::NetworkMessage::contentID |
When sending out a message, the application can attach a content ID to the message, which will effectively replace all the older messages with the same messageID and contentID.
Referenced by kNet::NetworkServer::BroadcastMessage(), kNet::MessageConnection::ClearOutboundMessageWithContentID(), kNet::MessageConnection::HandleInboundMessage(), kNet::MessageConnection::Send(), kNet::MessageConnection::SendMessage(), kNet::MessageConnection::SendStruct(), kNet::MessageConnection::SplitAndQueueMessage(), and kNet::MessageConnection::StartNewMessage().
If true, this message should be delivered reliably, possibly resent to guarantee that the receiving party gets it.
Referenced by kNet::NetworkServer::BroadcastMessage(), kNet::MessageConnection::EndAndQueueMessage(), kNet::MessageConnection::Send(), kNet::MessageConnection::SendMessage(), kNet::MessageConnection::SendStruct(), kNet::MessageConnection::SplitAndQueueMessage(), and kNet::MessageConnection::StartNewMessage().
If true, this message should be delivered in-order with all the other in-order messages.
The processing order of this message relative to non-in-ordered messages is not specified and can vary.
Referenced by kNet::NetworkServer::BroadcastMessage(), kNet::MessageConnection::Send(), kNet::MessageConnection::SendMessage(), kNet::MessageConnection::SendStruct(), and kNet::MessageConnection::SplitAndQueueMessage().
If this flag is set, the message will not be sent and will be deleted as soon as possible.
It has been superceded by another message before it had the time to leave the outbound send queue.
Referenced by kNet::MessageConnection::EndAndQueueMessage(), kNet::MessageConnection::SplitAndQueueMessage(), and kNet::MessageConnection::StartNewMessage().
1.7.1