Base class for NetConnection that provides only the sending functionality.
More...
Inherits G3D::ReferenceCountedObject.
Inherited by G3D::NetConnection.
|
virtual NetAddress | address () const |
| Address of the other side of the connection. More...
|
|
void | send (NetMessageType type, const void *bytes, size_t size, NetChannel channel=0, const shared_ptr< MemoryManager > &memoryManager=shared_ptr< MemoryManager >()) |
| Schedule for sending across this connection. More...
|
|
void | send (NetMessageType type, const void *bytes, size_t size, BinaryOutput &header, NetChannel channel=0, const shared_ptr< MemoryManager > &memoryManager=shared_ptr< MemoryManager >()) |
|
void | send (NetMessageType type, BinaryOutput &bo, NetChannel channel=0) |
| Send the contents of this BinaryOutput. More...
|
|
void | send (NetMessageType type, BinaryOutput &bo, BinaryOutput &header, NetChannel channel=0) |
| Includes a header. More...
|
|
void | shutdownSenderThreads () |
|
void | submitToSendQueues (const _internal::NetMessage &message) |
|
|
template<class T , class ... ArgTypes> |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
| Like std::make_shared, but works for protected constructors. More...
|
|
Base class for NetConnection that provides only the sending functionality.
This is only used for NetServer::broadcast(), where there is no analogous "broadcast receive". For most applications, use NetConnection.
◆ NetSendConnection()
G3D::NetSendConnection::NetSendConnection |
( |
_ENetPeer * |
p, |
|
|
_ENetHost * |
h |
|
) |
| |
|
inlineprotected |
◆ address()
virtual NetAddress G3D::NetSendConnection::address |
( |
| ) |
const |
|
virtual |
Address of the other side of the connection.
◆ beforeSend()
virtual void G3D::NetSendConnection::beforeSend |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ createShared()
template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared |
( |
ArgTypes &&... |
args | ) |
|
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
◆ enetsend()
virtual void G3D::NetSendConnection::enetsend |
( |
NetChannel |
channel, |
|
|
_ENetPacket * |
packet |
|
) |
| |
|
protectedvirtual |
Acutally send the packet with enet.
This allows code reuse with NetConnection, which has a different sending mechanism.
◆ processFreeQueue()
void G3D::NetSendConnection::processFreeQueue |
( |
| ) |
|
|
protected |
◆ send() [1/4]
Schedule for sending across this connection.
- Parameters
-
bytes | By default, the memory will be copied, so it is safe to deallocate or change on return |
memoryManager | If notNull, then this memory manager will be used to free bytes once the data has been transmitted. Do not modify or free bytes after invoking send(). If not provided, the contents of bytes are immediately copied and the caller is able to mutate or free it immediately on return. The memoryManagers are queued and can be invoked at the time of any future method invocation. This guarantees that they are run on a thread that the application controls (and not the internal network threads). |
Pass a memoryManager when sending large packets to avoid the overhead of copying. Do not pass a memoryManager for small packets, since there is some overhead in initializing the deallocation record.
- Parameters
-
Messages may be divided over individual packets if large, but are always observed outside of the API as atomic.
Not guaranteed to be delivered if a disconnection occurs on either side before the message is completely transferred, or if this is currently disconnected.
- See also
- networkSendBacklog
◆ send() [2/4]
◆ send() [3/4]
Send the contents of this BinaryOutput.
This is easier and safer to use than the other version of send(), so it is preferred for general use. However, this method copies the memory, so it is slightly slower than the other overloaded version of send() for large buffers.
- See also
- networkSendBacklog
◆ send() [4/4]
Includes a header.
The header should be fairly small to avoid increasing latency during the extra copies required.
◆ shutdownSenderThreads()
void G3D::NetSendConnection::shutdownSenderThreads |
( |
| ) |
|
◆ submitToSendQueues()
void G3D::NetSendConnection::submitToSendQueues |
( |
const _internal::NetMessage & |
message | ) |
|
◆ addCallback
void addCallback |
( |
const shared_ptr< NetSendConnection > & |
conn, |
|
|
_ENetPacket * |
packet, |
|
|
const shared_ptr< MemoryManager > & |
manager, |
|
|
const void * |
data |
|
) |
| |
|
friend |
◆ freePacketDataCallback
void freePacketDataCallback |
( |
_ENetPacket * |
packet | ) |
|
|
friend |
◆ NetServer
◆ m_enetHost
_ENetHost* G3D::NetSendConnection::m_enetHost |
|
protected |
◆ m_enetPeer
_ENetPeer* G3D::NetSendConnection::m_enetPeer |
|
protected |
◆ m_freeQueue
Callbacks to be run the next time any method is invoked.