cure v0.5.0 Cure.Server
The server is responsible for the communication between Elixir and C/C++. The communication is based on Erlang Ports.
Summary
Functions
Sends binary data to the C/C++ program that the server is connected with. The result is sent back to the process that called this function. The third argument indicates how the response should be handled. Possible modes for handling the response are the following
Sends binary data to the C/C++ program that the server is connected with. A callback-function (arity 1) can be added to handle the incoming response of the program. If no callback is added, the response will be sent to the calling process of this function
Sends binary data to the C/C++ program that the server is connected with. The server waits with processing further events until the response for this function is handled
Starts a Cure.Server process and opens a Port that can communicate with a C/C++ program
Starts a Cure.Server process, links it to the calling process and opens a Port that can communicate with a C/C++ program
Stops the server process
Subscribes the calling process to receive data events from the server process
Adds an extra callback function to the server that is triggered on all incoming data
Unsubscribes the calling process from receiving further data events coming from the server process
Removes a callback that was applied to all incoming data events. NOTE: this has to be the exact same callback function that was registered earlier with subscribe in order for this function to work properly
Functions
Sends binary data to the C/C++ program that the server is connected with. The result is sent back to the process that called this function. The third argument indicates how the response should be handled. Possible modes for handling the response are the following:
:once -> Only the first event will be sent back to the calling process. :noreply -> No event will be sent back to the calling process. :permanent -> All following events will be sent back to the calling process. :sync -> the server waits with processing further events until the response is sent back to the calling process (timeout = :infinity unless specified).
Specs
send_data(pid, binary, :once | :permanent | :sync, (binary -> any) | timeout) :: :ok
send_data(pid, binary, :once | :noreply | :permanent, :sync) ::
:ok |
{:error, term}
Sends binary data to the C/C++ program that the server is connected with. A callback-function (arity 1) can be added to handle the incoming response of the program. If no callback is added, the response will be sent to the calling process of this function.
The third argument indicates how the response should be handled. Possible modes for handling the response are the following:
:once -> callback function is only applied once. :permanent -> callback function is applied to all following events :sync -> the server waits with further events until response is processed (no timeout specified = :infinity).
Specs
send_data(pid, binary, :sync, (binary -> any), timeout) :: :ok
Sends binary data to the C/C++ program that the server is connected with. The server waits with processing further events until the response for this function is handled.
Specs
start(String.t) :: GenEvent.on_start
Starts a Cure.Server process and opens a Port that can communicate with a C/C++ program.
Specs
start_link(String.t) :: GenEvent.on_start
Starts a Cure.Server process, links it to the calling process and opens a Port that can communicate with a C/C++ program.
Specs
subscribe(pid) :: :ok
Subscribes the calling process to receive data events from the server process.
Specs
subscribe(pid, (binary -> any)) :: :ok
Adds an extra callback function to the server that is triggered on all incoming data.
Specs
unsubscribe(pid) :: :ok
Unsubscribes the calling process from receiving further data events coming from the server process.