Method: OpenC3::JsonDRbObject#method_missing

Defined in:
lib/openc3/io/json_drb_object.rb

#method_missing(method_name, *method_params, **keyword_params) ⇒ Object

Forwards all method calls to the remote service.

Parameters:

  • method_name (Symbol)

    Name of the method to call

  • method_params (Array)

    Array of parameters to pass to the method

  • keyword_params (Hash<Symbol, Variable>)

    Hash of keyword parameters

Returns:

  • The result of the method call. If the method raises an exception the same exception is also raised. If something goes wrong with the protocol a JsonDRbError exception is raised.

Raises:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/openc3/io/json_drb_object.rb', line 61

def method_missing(method_name, *method_params, **keyword_params)
  raise JsonDRbError, "Shutdown" if @shutdown
  @mutex.synchronize do
    @log = [nil, nil, nil]
    connect() if !@http
    json_rpc_request = JsonRpcRequest.new(method_name, method_params, keyword_params, @id)
    data = json_rpc_request.to_json(:allow_nan => true)
    token = keyword_params[:token]
    response_body = make_request(data: data, token: token)
    if !response_body or response_body.to_s.length < 1
      disconnect()
    else
      response = JsonRpcResponse.from_json(response_body)
      return handle_response(response: response)
    end
    error = "No response from server: #{@log[0]} ::: #{@log[1]} ::: #{@log[2]}"
    raise JsonDRbError, error
  end
end