View Source AMI.Client (AMI v0.1.0)
Client module to connect Asterisk server and login AMI.
Module fits to be used in a supervisor tree.
When connection is lost in case of network problems it will keep trying to re-connect again every 3 seconds.
example-using-with-supervisor
Example using with supervisor
children = [
%{
id: :pbx01,
start: {
AMI.Client,
:start_link,
[{'pbx01.myphones.com', 5038, "admin", "secret4", MyAMImodule}]
}
},
%{
id: :pbx02,
start: {
AMI.Client,
:start_link,
[{'127.0.0.1', 5038, "admin", "secret9", MyAMImodule}]
}
},
]
Supervisor.start_link(children, strategy: :one_for_one)
Link to this section Summary
Functions
Send AMI Action to all established connections via clients
Returns a specification to start this module under a supervisor.
Send AMI Action packet via established connection by client identified by addr
Starts a AMI client linked to the current process.
Link to this section Functions
@spec broadcast(action :: AMI.Action.t()) :: :ok
Send AMI Action to all established connections via clients
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec send(action :: AMI.Action.t(), addr :: String.t()) :: :ok
Send AMI Action packet via established connection by client identified by addr
Starts a AMI client linked to the current process.
Can be userd to start the Client in a supervisor tree.
options
Options
host- remote Asterisk host or IP to connectport- remote AMI portuser- AMI username as stringpasswd- AMI password as stringmodule- elixir module that uses AMI and which will receive all incoming events. See exmple in AMI module
example
Example
AMI.Client.start_link({'localhost', 5447, "admin", "5ecR37", MyModule})