Copyright © 2004 Enrique Marcote Peña
Version: 1.1, {07 June 2004} 11:56:47.
Behaviour: gen_fsm.
Authors: Enrique Marcote Peña (mpquique_at_users.sourceforge.net) [web site: http://oserl.sourceforge.net/].
A generic ESME SMPP session modeled as a FSM. It also implements the gen_connection behaviour.
Every SMPP session works over a single TCP/IP connection. If the underlying connection exits, the session is also terminated.
Session failures due to connection errors must be handled by the callback ESME.
Possible states for the ESME SMPP session are shown in the first row. Events are those in the first column. This table shows the next state given an event and the current state.
Operations issued by the other peer (SMSC) are treated asynchronously by the ESME session, thus represented by async events.
One instance
of this timer is started for each request.
On expiration, the request is considered unsuccessful.
The timer associated to a request is stopped when the corresponding response arrives.
A module implementing this behaviour must export these functions. Leaving a callback undefined crashes the entire session (when that particular function is called).
handle_outbind/3 | Forwards outbind operations (from the peer SMSC) to the callback ESME. |
handle_alert_notification/3 | Forwards alert_notification operations (from the peer SMSC) to the callback ESME. |
handle_operation/3 | Forwards data_sm and deliver_sm operations (from the peer SMSC) to the callback ESME. |
handle_unbind/3 | This callback forwards unbind requests (issued by a peer SMSC) to the callback ESME. |
Forwards outbind operations (from the peer SMSC) to the callback ESME.
Response is ignored by the session.
ESME is the ESME's process id, Session is the session process id.
Forwards alert_notification operations (from the peer SMSC) to the callback ESME.
Response is ignored by the session.
ESME is the ESME's process id, Session is the session process id.
Forwards data_sm and deliver_sm operations (from the peer SMSC) to the callback ESME.
The ParamList included in the response is used to construct the response PDU. If a command_status other than ESME_ROK is to be returned by the ESME in the response PDU, the callback should return the term {error, Error, ParamList}, where Error is the desired command_status error code.
ESME is the ESME's process id, Session is the session process id.
This callback forwards unbind requests (issued by a peer SMSC) to the callback ESME.
If ok returned an unbind_resp with a ESME_ROK command_status is sent to the MC and the session moves into the unbound state. When {error, Error} is returned by the ESME, the response PDU sent by the session to the MC will have an Error command_status and the session will remain on it's current bound state (bound_rx, bound_tx or bound_trx).
ESME is the ESME's process id, Session is the process id.
behaviour_info/1 | Gives information about the behaviour. |
bind_receiver/2 | Issues a bind_receiver operation on the session identified by FsmRef. |
bind_transceiver/2 | Issues a bind_transceiver operation on the session identified by FsmRef. |
bind_transmitter/2 | Issues a bind_transmitter operation on the session identified by FsmRef. |
bound_rx/2 | gen_fsm - StateName/2 callback implementation. |
bound_rx/3 | gen_fsm - StateName/3 callback implementation. |
bound_trx/2 | gen_fsm - StateName/2 callback implementation. |
bound_trx/3 | gen_fsm - StateName/3 callback implementation. |
bound_tx/2 | gen_fsm - StateName/2 callback implementation. |
bound_tx/3 | gen_fsm - StateName/3 callback implementation. |
broadcast_sm/2 | Issues a broadcast_sm operation on the session identified by FsmRef. |
cancel_broadcast_sm/2 | Issues a cancel_broadcast_sm operation on the session identified by FsmRef. |
cancel_sm/2 | Issues a cancel_sm operation on the session identified by FsmRef. |
code_change/4 | gen_fsm - code_change/4 callback implementation. |
data_sm/2 | Issues a data_sm operation on the session identified by FsmRef. |
handle_event/3 | gen_fsm - handle_event/3 callback implementation. |
handle_info/3 | gen_fsm - handle_info/3 callback implementation. |
handle_sync_event/4 | gen_fsm - handle_sync_event/4 callback implementation. |
init/1 | gen_fsm - init/1 callback implementation. |
open/2 | gen_fsm - StateName/2 callback implementation. |
open/3 | gen_fsm - StateName/3 callback implementation. |
outbound/2 | gen_fsm - StateName/2 callback implementation. |
outbound/3 | gen_fsm - StateName/3 callback implementation. |
query_broadcast_sm/2 | Issues a query_broadcast_sm operation on the session identified by FsmRef. |
query_sm/2 | Issues a query_sm operation on the session identified by FsmRef. |
replace_sm/2 | Issues a replace_sm operation on the session identified by FsmRef. |
start/3 | Starts the server setting self() as the session SMSC (owner). |
start/4 | Starts the server setting self() as the session SMSC (owner). |
start_link/3 | Starts the server setting self() as the session ESME (owner). |
start_link/4 | Starts the server setting self() as the session ESME (owner). |
stop/1 | Stops the fsm. |
submit_multi/2 | Issues a submit_multi operation on the session identified by FsmRef. |
submit_sm/2 | Issues a submit_sm operation on the session identified by FsmRef. |
terminate/3 | gen_fsm - terminate/3 callback implementation. |
unbind/1 | Issues an unbind operation on the session identified by FsmRef. |
unbound/2 | gen_fsm - StateName/2 callback implementation. |
unbound/3 | gen_fsm - StateName/3 callback implementation. |
behaviour_info(Other::Category) -> Info
Gives information about the behaviour.
bind_receiver(FsmRef, ParamList) -> Result
Issues a bind_receiver operation on the session identified by FsmRef.
bind_transceiver(FsmRef, ParamList) -> Result
Issues a bind_transceiver operation on the session identified by FsmRef.
bind_transmitter(FsmRef, ParamList) -> Result
Issues a bind_transmitter operation on the session identified by FsmRef.
bound_rx(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name bound_rx. Bound against a receiver ESME.
PDUs comming from the other peer (ESME) are received asynchronously.
bound_rx(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name bound_rx. Bound against a receiver ESME.
bound_trx(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name bound_trx. Bound against a transceiver ESME.
PDUs comming from the other peer (ESME) are received asynchronously.
bound_trx(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name bound_trx. Bound against a transceiver ESME.
bound_tx(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name bound_tx. Bound against a transmitter ESME.
PDUs comming from the other peer (ESME) are received asynchronously.
bound_tx(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name bound_tx. Bound against a transmitter ESME.
broadcast_sm(FsmRef, ParamList) -> Result
Issues a broadcast_sm operation on the session identified by FsmRef.
cancel_broadcast_sm(FsmRef, ParamList) -> Result
Issues a cancel_broadcast_sm operation on the session identified by FsmRef.
cancel_sm(FsmRef, ParamList) -> Result
Issues a cancel_sm operation on the session identified by FsmRef.
code_change(OldVsn, StateName, StateData, Extra) -> Result
gen_fsm - code_change/4 callback implementation. Convert process state when code is changed
data_sm(FsmRef, ParamList) -> Result
Issues a data_sm operation on the session identified by FsmRef.
handle_event(E::Event, StateName, StateData) -> Result
gen_fsm - handle_event/3 callback implementation. Handles events received by gen_fsm:send_all_state_event/2.
handle_info(Info, StateName, StateData) -> Result
gen_fsm - handle_info/3 callback implementation. Call on reception of any other messages than a synchronous or asynchronous event.
handle_sync_event(Event, From, StateName, StateData) -> Result
gen_fsm - handle_sync_event/4 callback implementation. Handles events received via gen_fsm:sync_send_all_state_event/2,3.
init(X1::Args) -> Result
gen_fsm - init/1 callback implementation. Initializes the the fsm.
open(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name open.
PDUs comming from the other peer (ESME) are received asynchronously.
open(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name open.
outbound(R::Event, S) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name outbound.
PDUs comming from the other peer (ESME) are received asynchronously.
outbound(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name outbound.
query_broadcast_sm(FsmRef, ParamList) -> Result
Issues a query_broadcast_sm operation on the session identified by FsmRef.
query_sm(FsmRef, ParamList) -> Result
Issues a query_sm operation on the session identified by FsmRef.
replace_sm(FsmRef, ParamList) -> Result
Issues a replace_sm operation on the session identified by FsmRef.
start(Mod, Socket, Timers) -> Result
Starts the server setting self() as the session SMSC (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
The gen_esme_session is not registered.
See also: start_link/3, gen_fsm:start/3.
start(Name, Mod, Socket, Timers) -> Result
Starts the server setting self() as the session SMSC (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
If Name = {local, TheName}, the gen_esme_session is registered locally as TheName. If Name = {global, TheName}, the gen_esme_session is registered globally as TheName.
See also: start_link/4, gen_fsm:start/4.
start_link(Mod, Socket, Timers) -> Result
Starts the server setting self() as the session ESME (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
The gen_esme_session is not registered.
See also: start_link/3, gen_fsm:start_link/3.
start_link(Name, Mod, Socket, Timers) -> Result
Starts the server setting self() as the session ESME (owner).
Timers is a timers record. Use the macro ?DEFAULT_TIMERS to set the default values.
Refer to oserl.hrl for more details on the timers record definition.
If Name = {local, TheName}, the gen_esme_session is registered locally as Atom. If Name = {global, TheName}, the gen_esme_session is registered globally as Atom.
See also: start_link/2, gen_fsm:start_link/4.
stop(FsmRef) -> ok
Equivalent to gen_fsm:send_all_state_event(FsmRef, die).
Stops the fsm. This function does *NOT* issue an unbind operation. The unbind must have been previously sent using the unbind/1 function.
See also: gen_fsm:send_all_state_event/2.
submit_multi(FsmRef, ParamList) -> Result
Issues a submit_multi operation on the session identified by FsmRef.
submit_sm(FsmRef, ParamList) -> Result
Issues a submit_sm operation on the session identified by FsmRef.
terminate(R::Reason, N::StateName, S::StateData) -> true
gen_fsm - terminate/3 callback implementation. Shutdown the fsm.
Return value is ignored by the server.
unbind(FsmRef) -> Result
Issues an unbind operation on the session identified by FsmRef.
unbound(R::Event, S::StateData) -> Result
gen_fsm - StateName/2 callback implementation. Handles async events for the state name unbound.
PDUs comming from the other peer (ESME) are received asynchronously.
unbound(Event, From, S::StateData) -> Result
gen_fsm - StateName/3 callback implementation. Handles events for the state name unbound.