class JsonRpc::WebSocketClient

Overview

Implements JSON-RPC over WebSocket.

Included Modules

Defined in:

json_rpc/websocket_client.cr

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(socket : HTTP::WebSocket, remote_address : String, run : Bool = true) #

Creates a WebSocketClient from a HTTP::WebSocket. 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 #
Description copied from class JsonRpc::Client

Closes the connection.


[View source]
def inspect(io) #

[View source]
def remote_address : String #
Description copied from class JsonRpc::Client

Returns the remote address for display/logging purposes


[View source]
def run #

Starts the HTTP::WebSocket 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 socket : HTTP::WebSocket #

[View source]