acs_ex v0.3.7 ACS.Session

The actual ACS-CPE session is handled here. A session is initiated when an Inform arrives, therefore the init function takes a parsed Inform request as an argument.

We let the supervisor handle the main session handler, and then we register new sessions with the session_begins method

Summary

Functions

Returns a specification to start this module under a supervisor

Processes a message from the plug. “message” is the CWMP.Protocol version of the parsed request sent into the plug

Used for :trap_exit

Invoked when the server is started. start_link/3 or start/3 will block until it returns

when stuff is sent into this session, like CWMP messages or other stuff

Script message. This means the a scripting process wants a response to a request we just put the request in the plug queue and answer no_reply here

this is spawn_linked and should apply the call to the module

When something non-Inform’ish is sent into the session we need to find and verify the session

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

handle_call(msg, from, state)

Processes a message from the plug. “message” is the CWMP.Protocol version of the parsed request sent into the plug.

handle_info(msg, state)

Used for :trap_exit

  1. signal with reply/2 that this is over
  2. kill me?
has_inform?(list)
init(list)

Invoked when the server is started. start_link/3 or start/3 will block until it returns.

args is the argument term (second argument) passed to start_link/3.

Returning {:ok, state} will cause start_link/3 to return {:ok, pid} and the process to enter its loop.

Returning {:ok, state, timeout} is similar to {:ok, state} except handle_info(:timeout, state) will be called after timeout milliseconds if no messages are received within the timeout.

Returning {:ok, state, :hibernate} is similar to {:ok, state} except the process is hibernated before entering the loop. See c:handle_call/3 for more information on hibernation.

Returning :ignore will cause start_link/3 to return :ignore and the process will exit normally without entering the loop or calling c:terminate/2. If used when part of a supervision tree the parent supervisor will not fail to start nor immediately try to restart the GenServer. The remainder of the supervision tree will be (re)started and so the GenServer should not be required by other processes. It can be started later with Supervisor.restart_child/2 as the child specification is saved in the parent supervisor. The main use cases for this are:

  • The GenServer is disabled by configuration but might be enabled later.
  • An error occurred and it will be handled by a different mechanism than the Supervisor. Likely this approach involves calling Supervisor.restart_child/2 after a delay to attempt a restart.

Returning {:stop, reason} will cause start_link/3 to return {:error, reason} and the process to exit with reason reason without entering the loop or calling c:terminate/2.

Callback implementation for GenServer.init/1.

process_message(session_id, message)

when stuff is sent into this session, like CWMP messages or other stuff.

script_command(device_id, command)

Script message. This means the a scripting process wants a response to a request we just put the request in the plug queue and answer no_reply here.

session_prestart(gspid, script_module, device_id, message, sessionid, fun)

this is spawn_linked and should apply the call to the module

start_link(list, session_id, device_id, message, fun \\ nil)

For the supervisor.

verify_session(session_id, remote_host)

When something non-Inform’ish is sent into the session we need to find and verify the session.