Elixir MOM v0.5.3 MOM.RPC.Client

Standard layout for clients: JSON, Method caller and manual caller.

It can be a TCP/Websocket client that need to be authenticated, or Command clients that are given authentication credentials at creation.

As the functions are quite clear, it implements all necesary proxy functions so that its easy to add functions to the method caller, call functions at the remote server and parse lines from it.

There is a diagram at /docs/RPC-clients.svg.

Summary

Functions

add_method(client, name, f, options \\ [])
add_method_caller(client, mc, options \\ [])
call(client, method, param)
event(client, method, param)
get(client, what, default \\ nil)
parse_line(client, line)
set(client, what, value)
start_link(options \\ [])

Starts a communication with a client.

Comunication is using JSON RPC.

At initialization a function to write into the other end must be suplied, and new lines are added calling parse_line.

Options

  • name — Provides a name for this connection. For debug pourposes.
  • writef(line) — is a function that receives a line and writes it to the client.

writef is a mandatory option

stop(client, reason \\ :normal)