Skip to content

QuantumGate::Extender::SendMessage

Karel Donk edited this page Oct 27, 2021 · 4 revisions

Sends data to a peer on the network. This function attempts to send as much data as possible depending on the room available in the peer send buffer. If the peer send buffer is full the function call fails and can be retried. If some, or all, data has been sent, the function returns the size of the data in bytes that it was able to send. The rest of the data can then be sent in another call to the function (after removing the data that was already sent from the buffer).

Signature

  1. Result<Size> SendMessage(const PeerLUID pluid, Buffer&& buffer, const SendParameters& params,
                             SendCallback&& callback = nullptr) const noexcept;
  2. Result<Size> SendMessage(Peer& peer, Buffer&& buffer, const SendParameters& params,
                             SendCallback&& callback = nullptr) const noexcept;

Parameters

Name Description
pluid A QuantumGate::PeerLUID with the Locally Unique Identifier of the connected peer.
peer A QuantumGate::Peer object representing the connected peer.
buffer A QuantumGate::Buffer object containing the data to send. The size of the buffer should not be greater than the value returned by the QuantumGate::Extender::GetMaximumMessageDataSize function.
params A QuantumGate::SendParameters object containing the parameters to use when sending.
callback A QuantumGate::SendCallback object containing the function to call after the data has been sent. See QuantumGate Callbacks for more details. This parameter defaults to nullptr. Note that QuantumGate doesn't guarantee that the data has actually been delivered when this callback gets invoked -- only that it has been transmitted or is in the process of being transmitted. Extenders should implement their own mechanisms for acknowledging that the data has actually been delivered when required.

Return values

Returns a QuantumGate::Result object containing, upon successful completion, the Size of the data that was sent from the buffer. The QuantumGate::Result object will equal one of the following QuantumGate::ResultCodes:

Value Description
QuantumGate::ResultCode::Succeeded The operation succeeded.
QuantumGate::ResultCode::Failed The operation failed.
QuantumGate::ResultCode::FailedRetry The operation failed but can be retried. This can happen when the extender is not yet (fully) ready.
QuantumGate::ResultCode::OutOfMemory The operation failed because of a memory allocation failure.
QuantumGate::ResultCode::PeerNotFound The operation failed because the peer wasn't found.
QuantumGate::ResultCode::PeerNoExtender The operation failed because the peer doesn't have the extender running.
QuantumGate::ResultCode::PeerNotReady The operation failed because the peer wasn't ready (it may still be connecting or was disconnected).
QuantumGate::ResultCode::PeerSendBufferFull The operation failed because the send buffer for the peer is full. Retry sending later.
QuantumGate::ResultCode::PeerSuspended The operation failed because the connection to the peer is suspended. Retry sending later.
QuantumGate::ResultCode::NotRunning The operation failed because either the local instance or the extender isn't running.
Clone this wiki locally