Method ConnectAsync
- Namespace
- WhalesSecret.TradeScriptLib.API
- Assembly
- WhalesSecret.TradeScriptLib.dll
ConnectAsync(Uri, string, NewExternalDataHandlerAsync, ExternalDataErrorHandlerAsync?)
Connects to the external source of data as a client. This method can only be called once in the trade script's lifetime.
Task ConnectAsync(Uri uri, string issuerPublicKeyHex, IExternalApiV1.NewExternalDataHandlerAsync newDataHandler, IExternalApiV1.ExternalDataErrorHandlerAsync? errorHandler = null)
Parameters
uriUriHTTP(s) URI of the external data feed.
issuerPublicKeyHexstringPublic key of the external data issuer in hex format. The public key is an EC point calculated from the private key and it is exported as a concatenation of binary representations of X and Y coordinates of the EC point. Therefore, the expected value is formed as
hex(pubKey.X||pubKey.Y). The key is used for verification of the signature of the external data.newDataHandlerIExternalApiV1.NewExternalDataHandlerAsyncCallback method that is called when new data is received from the external data source.
errorHandlerIExternalApiV1.ExternalDataErrorHandlerAsyncCallback method that is called when an error occurs while an attempt to get external data was made.
Returns
Exceptions
- AlreadyExistsException
Thrown when the method is called more than once in the trade script's lifetime.
- InvalidArgumentException
Thrown if
uriorissuerPublicKeyHexornewDataHandlerisnull, or ifuriis not Absolute, or ifissuerPublicKeyHexis not a valid public key encoded in hex format.
- See Also
ConnectAsync(Uri, string, TimeSpan?, NewExternalDataHandlerAsync, ExternalDataErrorHandlerAsync?)
Connects to the external source of data as a client. This method can only be called once in the trade script's lifetime.
Task ConnectAsync(Uri uri, string issuerPublicKeyHex, TimeSpan? downloadTimeout, IExternalApiV1.NewExternalDataHandlerAsync newDataHandler, IExternalApiV1.ExternalDataErrorHandlerAsync? errorHandler = null)
Parameters
uriUriHTTP(s) URI of the external data feed.
issuerPublicKeyHexstringPublic key of the external data issuer in hex format. The public key is an EC point calculated from the private key and it is exported as a concatenation of binary representations of X and Y coordinates of the EC point. Therefore, the expected value is formed as
hex(pubKey.X||pubKey.Y). The key is used for verification of the signature of the external data.downloadTimeoutTimeSpan?Timeout for a single download operation, or
nullnot to have a time limit for the download operation. This specifies how long does the client wait for the external data source to send the response before considering the attempt as failed.newDataHandlerIExternalApiV1.NewExternalDataHandlerAsyncCallback method that is called when new data is received from the external data source.
errorHandlerIExternalApiV1.ExternalDataErrorHandlerAsyncCallback method that is called when an error occurs while an attempt to get external data was made.
Returns
Exceptions
- AlreadyExistsException
Thrown when the method is called more than once in the trade script's lifetime.
- InvalidArgumentException
Thrown if
uriorissuerPublicKeyHexornewDataHandlerisnull, or ifuriis not Absolute, or ifissuerPublicKeyHexis not a valid public key encoded in hex format.
- See Also