sendJson method

int sendJson(
  1. String method, [
  2. Map<String, dynamic>? params
])

Sends a JSON message to the WebSocket server

Implementation

int sendJson(String method, [Map<String, dynamic>? params]) {
  final id = rpcId;
  rpcId++;

  final jsonObject = <String, dynamic>{
    'jsonrpc': JsonConstants.jsonRpcVersion,
    'method': method,
    'id': id,
    'params': params ?? {},
  };

  final jsonString = jsonEncode(jsonObject);
  webSocket?.add(jsonString);
  return id;
}