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
uri
UriHTTP(s) URI of the external data feed.
issuerPublicKeyHex
stringPublic 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.newDataHandler
IExternalApiV1.NewExternalDataHandlerAsyncCallback method that is called when new data is received from the external data source.
errorHandler
IExternalApiV1.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
uri
orissuerPublicKeyHex
ornewDataHandler
isnull
, or ifuri
is not Absolute, or ifissuerPublicKeyHex
is 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
uri
UriHTTP(s) URI of the external data feed.
issuerPublicKeyHex
stringPublic 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.downloadTimeout
TimeSpan?Timeout for a single download operation, or
null
not 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.newDataHandler
IExternalApiV1.NewExternalDataHandlerAsyncCallback method that is called when new data is received from the external data source.
errorHandler
IExternalApiV1.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
uri
orissuerPublicKeyHex
ornewDataHandler
isnull
, or ifuri
is not Absolute, or ifissuerPublicKeyHex
is not a valid public key encoded in hex format.
- See Also