Connection constructor

Connection(
  1. Cluster httpCluster, {
  2. Cluster? websocketCluster,
  3. Commitment? commitment = Commitment.confirmed,
})

Creates a connection to invoke JSON RPC methods.

Implementation

Connection(
  this.httpCluster, {
  final Cluster? websocketCluster,
  this.commitment = Commitment.confirmed,
}) : websocketCluster = websocketCluster ?? httpCluster.toWebsocket() {
  httpClient = JsonRpcHttpClient(httpCluster.uri);
  websocketClient = JsonRpcWebsocketClient.withStringDecoder(
    this.websocketCluster.uri,
    onConnect: onWebsocketConnect,
    onDisconnect: onWebsocketDisconnect,
    onData: onWebsocketData,
    onError: onWebsocketError,
  );
}