class JsonRpc::StreamClient

Overview

Implements JSON-RPC over a persistant data stream.

Included Modules

Direct Known Subclasses

Defined in:

json_rpc/stream_client.cr

Constant Summary

SIZE_LIMIT = (2 * 1024) * 1024

Constructors

Instance Method Summary

Instance methods inherited from module JsonRpc::Stream

process_document(document : String) process_document, recv_message(id) recv_message

Instance methods inherited from class JsonRpc::Client

async_call : Bool async_call, async_call=(async_call : Bool) async_call=, call(result_type, method : String, params = nil) call, call?(result_type, method : String, params = nil) call?, close close, connection_lost : Signal_connection_lost connection_lost, fatal_local_error : Signal_fatal_local_error fatal_local_error, fatal_remote_error : Signal_fatal_remote_error fatal_remote_error, flood_messages : Int32 | Nil flood_messages, flood_messages=(flood_messages : Int32 | Nil) flood_messages=, flood_protection_triggered : Signal_flood_protection_triggered flood_protection_triggered, flood_time_span : Time::Span flood_time_span, flood_time_span=(flood_time_span : Time::Span) flood_time_span=, handler : Handler handler, handler=(handler : Handler) handler=, invoke_from_remote(request : Request, raw : String) : Nil invoke_from_remote, messages_received : UInt64 messages_received, messages_sent : UInt64 messages_sent, notification : Signal_notification notification, notify(method : String, params = nil) notify, notify_raw(message : String) notify_raw, recv_message(id) recv_message, remote_address : String remote_address, running? : Bool running?, send_message(id, message_data : String) send_message, send_response(response : Response) send_response

Constructor methods inherited from class JsonRpc::Client

new new

Constructor Detail

def self.new(stream : JsonRpc::DocumentStream, remote_address : String, run = true) #

Creates a streaming client from stream. If run is true, the client will start accepting messages right away. If you choose to pass false, then make sure to call #run some time afterwards manually, even if you're only calling remote methods.


[View source]

Instance Method Detail

def close #

Closes the stream.


[View source]
def inspect(io) #

[View source]
def read_loop #

Runs the read-loop in the current fiber, blocking it. See #run.


[View source]
def read_once #

Waits for exactly one document to arrive and processes it.


[View source]
def remote_address : String #

The remote address


[View source]
def request_size_limit : Int32 #

Maximum request size limit. If a client exceeds this, it will be disconnected. Defaults to SIZE_LIMIT


[View source]
def request_size_limit=(request_size_limit : Int32) #

Maximum request size limit. If a client exceeds this, it will be disconnected. Defaults to SIZE_LIMIT


[View source]
def run #

Starts the read-loop in a background fiber. Make sure to only call this method once, and only if you passed false for run to the constructor.

If you did not do anything fancy, don't call this method.


[View source]
def send_message(_id, message_data) #

Interface for JsonRpc::Client


[View source]
def stream : DocumentStream #

[View source]