Skip to content

QuantumGate::Local::ConnectTo

Karel Donk edited this page Aug 16, 2020 · 11 revisions

Initiates a connection to a peer on the network and either returns immediately (1) or blocks until the connection has been made or the attempt failed (2). When the connection is established, or when it fails, the ConnectCallback function gets called if one was supplied (1). If there was an existing connection to that peer, that connection is re-used.

Signature

  1.  Result<std::pair<PeerLUID, bool>>
         ConnectTo(ConnectParameters&& params,
             ConnectCallback&& function) noexcept;
  2.  Result<Peer> ConnectTo(ConnectParameters&& params) noexcept;

Parameters

Name Description
params A QuantumGate::ConnectParameters object containing the connection parameters.
function A QuantumGate::ConnectCallback object containing the function to call when the connection was successful or unsuccessful. This function doesn't get called when an existing connection is re-used. See QuantumGate Callbacks for more details. This parameter can be nullptr.

Return values

  1. Returns a QuantumGate::Result containing, upon successful completion, a std::pair with a QuantumGate::PeerLUID and a bool. The QuantumGate::PeerLUID contains the Locally Unique Identifier of the peer upon successful initiation of the connection. The bool value indicates whether an existing connection was reused (true if so). Note that it's possible in the case of a reused connection that the connection is still in the process of being fully established.

  2. Returns a QuantumGate::Result containing, upon successful completion, a QuantumGate::Peer object representing the connected peer.

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 a retry can be successful.
QuantumGate::ResultCode::NotRunning The operation failed because the instance isn't running.
QuantumGate::ResultCode::NotAllowed The operation failed because a connection to the specified endpoint is not allowed by the configured security and access settings.
QuantumGate::ResultCode::NoPeersForRelay The operation failed because there were no connected peers through which to establish a relayed connection.
Clone this wiki locally