Skip to content

QuantumGate::Local::ConnectTo

Karel Donk edited this page Jun 2, 2018 · 11 revisions

Connects to a peer on the network. If there was an existing connection to that peer, that connection is re-used.

Signature

const std::pair<Result, PeerLUID> ConnectTo(const IPEndPoint& endpoint,
                                            ConnectCallback&& connect_func = nullptr,
                                            DisconnectCallback&& disconnect_func = nullptr) noexcept;

Parameters

Name Description
endpoint A QuantumGate::IPEndPoint object containing the endpoint to connect to. See QuantumGate::IPEndPoint for more details.
connect_func A QuantumGate::ConnectCallback object containing the function to call when the connection was successful. This function doesn't get called when an existing connection is re-used. See QuantumGate Callbacks for more details.
disconnect_func A QuantumGate::DisconnectCallback object containing the function to call when the connection closes after having been established. This function doesn't get called when an existing connection is re-used. See QuantumGate Callbacks for more details.

Return values

Returns a std::pair containing a QuantumGate::Result and a PeerLUID. The PeerLUID contains the Locally Unique Identifier for the peer upon successful connection. The QuantumGate::Result object can contain one of the following QuantumGate::ResultCodes:

Value Description
QuantumGate::ResultCode::Succeeded The operation succeeded.
QuantumGate::ResultCode::SucceededAlreadyConnected The operation succeeded and an existing connection is being re-used. The PeerLUID of the existing connection is returned.
QuantumGate::ResultCode::Failed The operation failed.
QuantumGate::ResultCode::FailedRetry The operation failed but can be retried.
QuantumGate::ResultCode::FailedNotRunning The operation failed because the instance isn't running.
QuantumGate::ResultCode::FailedNotAllowed The operation failed because a connection to the specified endpoint is not allowed by the configured security and access settings.
Clone this wiki locally