- 
                Notifications
    You must be signed in to change notification settings 
- Fork 23
QuantumGate::Local::ConnectTo
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.
- 
Result<std::pair<PeerLUID, bool>> ConnectTo(ConnectParameters&& params, ConnectCallback&& function) noexcept; 
- 
Result<Peer> ConnectTo(ConnectParameters&& params) noexcept; 
| Name | Description | 
|---|---|
| params | A QuantumGate::ConnectParametersobject containing the connection parameters. | 
| function | A QuantumGate::ConnectCallbackobject 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 benullptr. | 
- 
Returns a QuantumGate::Resultcontaining, upon successful completion, astd::pairwith aQuantumGate::PeerLUIDand abool. TheQuantumGate::PeerLUIDcontains the Locally Unique Identifier of the peer upon successful initiation of the connection. Theboolvalue indicates whether an existing connection was reused (trueif 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.
- 
Returns a QuantumGate::Resultcontaining, upon successful completion, aQuantumGate::Peerobject 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. |