Method: Ccrpc::RpcConnection::Call#call_back

Defined in:
lib/ccrpc/rpc_connection.rb

#call_back(func, params = {}, &block) ⇒ Object

Send a dedicated callback to the caller’s block.

If Ccrpc::RpcConnection#call is called with both function name and block, then it’s possible to call back to this dedicated block through #call_back . The library ensures, that the callback ends up in the corresponding call block and in the same thread as the caller, even if there are multiple simultaneous calls are running at the same time in different threads or by using lazy_answers .

Yielded parameters and returned objects are described in Ccrpc::RpcConnection#call.

Parameters:

  • func (String, Symbol)

    The RPC function to be called on the other side. The other side must wait for calls through Ccrpc::RpcConnection#call with function name and with a block.

  • params (Hash{Symbol, String => Symbol, String}) (defaults to: {})

    Optional parameters passed with the RPC call. They can be retrieved through #params on the receiving side.

Raises:



72
73
74
75
# File 'lib/ccrpc/rpc_connection.rb', line 72

def call_back(func, params={}, &block)
  raise CallAlreadyReturned, "Callback is no longer possible since the call already returned #{self.inspect}" if @answer
  conn.send(:call_intern, func, params, @id, &block)
end