json_rpc/clients/socketclient

Source   Edit  

Types

Framing = object
Source   Edit  
RpcSocketClient = ref object of RpcConnection
  transport*: StreamTransport
  loop*: Future[void]
  framing*: Framing
StreamTransport-based bidirectional connection with pluggable framing options for delineating messages. Source   Edit  

Procs

proc attach(client: RpcSocketClient; transport: StreamTransport; remote: string): InternalRaisesFuture[
    void, void] {....stackTrace: false, raises: [], gcsafe, raises: [], gcsafe,
                  tags: [RootEffect], forbids: [].}
Source   Edit  
proc connect(client: RpcSocketClient; address: string; port: Port): InternalRaisesFuture[
    void, (CancelledError, JsonRpcError)] {....stackTrace: false, raises: [],
    gcsafe, raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit  
proc connect(client: RpcSocketClient; address: TransportAddress): InternalRaisesFuture[
    void, (CancelledError, JsonRpcError)] {....stackTrace: false, raises: [],
    gcsafe, raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit  
proc httpHeader(T: type Framing): T:type {....raises: [], gcsafe.}

Framing using a HTTP-like Content-Length: <length>\r\n header followed by an empty line ("rn") followed by a the message itself.

This encoding is compatible with the default encoding used by StreamJsonRPC and https://www.npmjs.com/package/vscode-jsonrpc.

For a higher-performance option, use Framing.lengthHeaderBE32.

Source   Edit  
proc lengthHeaderBE32(T: type Framing): T:type {....raises: [], gcsafe.}
Framing using a HTTP-like Content-Length header followed by two newlines to delimit each message. Source   Edit  
proc new(T: type RpcSocketClient; maxMessageSize = defaultMaxMessageSize;
         router = default(ref RpcRouter); framing = Framing.newLine()): T:type {.
    ...raises: [], gcsafe.}
Source   Edit  
proc new(T: type RpcSocketClient; maxMessageSize = defaultMaxMessageSize;
         router = default(RpcRouterCallback); framing = Framing.newLine()): T:type {.
    ...raises: [], gcsafe.}
Source   Edit  
proc newLine(T: type Framing): T:type {....deprecated: "Prefer lengthHeaderBE32 or httpHeader in in new applications",
                                        raises: [], gcsafe.}
Deprecated: Prefer lengthHeaderBE32 or httpHeader in in new applications

A framing that suffixes messages with "rn". This framing is supported only for historical purposes and may be removed in a future version.

The framing can only be used with payloads that do not contain newlines and message length is checked only after that many bytes have been transmitted.

Source   Edit  
proc newRpcSocketClient(maxMessageSize = defaultMaxMessageSize;
                        router = default(ref RpcRouter);
                        framing = Framing.newLine()): RpcSocketClient {.
    ...raises: [], gcsafe, tags: [], forbids: [].}
Creates a new client instance. Source   Edit  

Methods

method close(client: RpcSocketClient): InternalRaisesFuture[void, void] {.
    ...stackTrace: false, raises: [], gcsafe, raises: [], gcsafe,
    tags: [RootEffect], forbids: [].}
Source   Edit  
method request(client: RpcSocketClient; reqData: seq[byte]): InternalRaisesFuture[
    seq[byte], (CancelledError, JsonRpcError)] {....stackTrace: false, raises: [],
    gcsafe, raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Remotely calls the specified RPC method. Source   Edit  
method send(client: RpcSocketClient; reqData: seq[byte]): InternalRaisesFuture[
    void, (CancelledError, JsonRpcError)] {....stackTrace: false, raises: [],
    gcsafe, raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Source   Edit