Copyright © 2004 Enrique Marcote Peña
Version: 1.1, {13 May 2004} 11:56:47.
Behaviour: gen_server, gen_smsc_session.
Authors: Enrique Marcote Peña (mpquique_at_users.sourceforge.net) [web site: http://oserl.sourceforge.net/].
A generic SMSC implemented as a gen_server.
This behaviour acts as an extended gen_server, homonymous functions have the exact same meaning.
By default sessions are NOT linked to the parent SMSC, thus silently dropped if an error occurs. To monitor sessions, SMSC programmers may either use erlang:monitor(process, Session) or explicitly create a link to them.
SMPP operations are directly issued upon sessions, they don't go through the SMSC server loop. This means you may call the functions session_start/2, session_start/3, session_stop/1, alert_notification/2, outbind/2, deliver_sm/2 , data_sm/2 or unbind/1 from within any callback without having the risk of blocking the SMSC server.
Please refer to test_smsc.erl for a minimal SMSC example. There is also a SMSC skeleton you may use as the starting point of your SMSC development, find the module smsc_skel.erl under doc/examples directory.
A module implementing this behaviour must export these functions. Leaving a callback undefined crashes the entire SMSC whenever that particular function is called.
init/1 | Forwards gen_server:init/1 callbacks to the SMSC server. | |
handle_bind/3 | Forwards bind_receiver, bind_transmitter and bind_transceiver operations (from the peer ESMEs) to the callback SMSC. | |
handle_operation/3 | Forwards broadcast_sm, cancel_broadcast_sm, cancel_sm, query_broadcast_sm, query_sm, replace_sm, submit_multi, submit_sm and data_sm operations (from the peer ESMEs) to the callback SMSC. | |
handle_unbind/3 | This callback forwards an unbind request (issued by peer ESMEs) to the SMSC. | |
handle_listen_error/1 | Notifies listen socket failures to the callback SMSC. | |
handle_call/3 | Forwards gen_server:handle_call/3 callbacks to the SMSC server. | |
handle_cast/2 | Forwards gen_server:handle_cast/2 callbacks to the SMSC server. | . |
handle_info/2 | Forwards gen_server:handle_info/2 callbacks to the SMSC server. | . |
terminate/2 | Forwards gen_server:terminate/2 callbacks to the SMSC server. | . |
code_change/3 | Forwards gen_server:code_change/3 callbacks to the SMSC server. | . |
Forwards gen_server:init/1 callbacks to the SMSC server.
Refer to OTP gen_server behaviour documentation for greater details on this callback.
Forwards bind_receiver, bind_transmitter and bind_transceiver operations (from the peer ESMEs) to the callback SMSC.
The ParamList included in the response is used to construct the bind response PDU. If a command_status other than ESME_ROK is to be returned by the SMSC in the response PDU, the callback should return the term {error, Error, ParamList}, where Error is the desired command_status error code.
Forwards broadcast_sm, cancel_broadcast_sm, cancel_sm, query_broadcast_sm, query_sm, replace_sm, submit_multi, submit_sm and data_sm operations (from the peer ESMEs) to the callback SMSC.
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 SMSC in the response PDU, the callback should return the term {error, Error, ParamList}, where Error is the desired command_status error code.
This callback forwards an unbind request (issued by peer ESMEs) to the SMSC.
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).
Notifies listen socket failures to the callback SMSC.
Forwards gen_server:handle_call/3 callbacks to the SMSC server.
Refer to OTP gen_server behaviour documentation for greater details on this callback.
Forwards gen_server:handle_cast/2 callback to the SMSC server.
Refer to OTP gen_server behaviour documentation for greater details on this callback.
Forwards gen_server:handle_info/2 callback to the SMSC server.
Refer to OTP gen_server behaviour documentation for greater details on this callback.
Forwards gen_server:terminate/2 callback to the SMSC server.
Refer to OTP gen_server behaviour documentation for greater details on this callback.
Forwards gen_server:code_change/3 callback to the SMSC server.
Refer to OTP gen_server behaviour documentation for greater details on this callback.
alert_notification/2 | Issues an alert_notification operation on the session identified by Session. |
behaviour_info/1 | Gives information about the behaviour. |
call/2 | Equivalent to gen_server:call/2. |
call/3 | Equivalent to gen_server:call/3. |
cast/2 | Equivalent to gen_server:cast/2. |
code_change/3 | gen_server - code_change/3 callback implementation. |
data_sm/2 | Issues a data_sm operation on the session identified by Session. |
deliver_sm/2 | Issues a deliver_sm operation on the session identified by Session. |
handle_bind/3 | gen_smsc_session - handle_bind/3 callback implementation. |
handle_call/3 | gen_server - handle_call/3 callback implementation. |
handle_cast/2 | gen_server - handle_cast/2 callback implementation. |
handle_info/2 | gen_server - handle_info/2 callback implementation. |
handle_operation/3 | gen_smsc_session - handle_operation/3 callback implementation. |
handle_unbind/3 | gen_smsc_session - handle_unbind/3 callback implementation. |
init/1 | gen_server - init/1 callback implementation. |
listen_start/1 | Puts the SMSC Server ServerRef to listen on DEFAULT_SMPP_PORT. |
listen_start/4 | Puts the SMSC Server ServerRef to listen on Port
Timers is a timers record as declared in oserl.hrl. Accepted session will be subject to given timers. Only Count connections are accepted. Started sessions are NOT linked to the SMSC. . |
listen_stop/1 | Stops listening. |
outbind/2 | Issues an outbind operation on the session identified by Session. |
reply/2 | Equivalent to gen_server:reply/2. |
session_start/2 | Opens a new session. |
session_start/3 | Opens a new session. |
session_stop/1 | Stops the Session. |
start/3 | Starts the SMSC server. |
start/4 | Starts the SMSC server. |
start_link/3 | Starts the SMSC server. |
start_link/4 | Starts the SMSC server. |
terminate/2 | gen_server - terminate/2 callback implementation. |
unbind/1 | Issues an unbind operation on the session identified by Session. |
alert_notification(Session, ParamList) -> ok
Issues an alert_notification operation on the session identified by Session.
behaviour_info(Other::Category) -> Info
Gives information about the behaviour.
call(ServerRef, Request) -> Reply
Equivalent to gen_server:call/2.
Request is an arbitrary term which is passed as one of the arguments to Module:handle_call/3.
Please refer to the gen_server man page for greater details.
call(ServerRef, Request, Timeout) -> Reply
Equivalent to gen_server:call/3.
Request is an arbitrary term which is passed as one of the arguments to Module:handle_call/3.
Please refer to the gen_server man page for greater details.
cast(ServerRef, Request) -> Reply
Equivalent to gen_server:cast/2.
Request is an arbitrary term which is passed as one of the arguments to Module:handle_cast/2.
Please refer to the gen_server man page for greater details.
code_change(OldVsn, S::State, Extra) -> {ok, NewState}
gen_server - code_change/3 callback implementation.
Convert process state when code is changed.
data_sm(Session, ParamList) -> Result
Issues a data_sm operation on the session identified by Session.
deliver_sm(Session, ParamList) -> Result
Issues a deliver_sm operation on the session identified by Session.
handle_bind(ServerRef, Session, X3::{CmdName, Pdu}) -> Result
gen_smsc_session - handle_bind/3 callback implementation.
handle_call(R::Request, From, S::State) -> Result
gen_server - handle_call/3 callback implementation.
Handling call messages.
See also: terminate/2.
handle_cast(X1::Request, S::State) -> Result
gen_server - handle_cast/2 callback implementation.
Handling cast messages.
See also: terminate/2.
handle_info(Info, S::State) -> Result
gen_server - handle_info/2 callback implementation.
Handling all non call/cast messages.
See also: terminate/2.
handle_operation(ServerRef, Session, X3::{CmdName, Pdu}) -> Result
gen_smsc_session - handle_operation/3 callback implementation.
handle_unbind(ServerRef, Session, Pdu) -> ok | {error, Error}
gen_smsc_session - handle_unbind/3 callback implementation.
init(X1::Args) -> Result
gen_server - init/1 callback implementation.
Initiates the server.
listen_start(ServerRef) -> ok | {error, Reason}
Equivalent to listen(ServerRef, DEFAULT_SMPP_PORT, infinity, DEFAULT_SMPP_TIMERS).
Puts the SMSC Server ServerRef to listen on DEFAULT_SMPP_PORT.
By default infinity connections are accepted. Started sessions are NOT linked to the SMSC.
See also: listen_start/4.
listen_start(ServerRef, Port, Count, Timers) -> ok | {error, Reason}
Puts the SMSC Server ServerRef to listen on Port
Timers is a timers record as declared in oserl.hrl. Accepted session will be subject to given timers.
Only Count connections are accepted. Started sessions are NOT linked to the SMSC.
See also: listen_start/1.
listen_stop(ServerRef) -> ok
Stops listening.
outbind(Session, ParamList) -> ok
Issues an outbind operation on the session identified by Session.
reply(Client, Reply) -> true
Equivalent to gen_server:reply/2.
Please refer to the gen_server man page for greater details.
session_start(Address, Port) -> Result
Equivalent to session_start(Address, Port, DEFAULT_SMPP_TIMERS).
Opens a new session. By default Sessions are NOT linked to the SMSC.
Returns {ok, Session} if success, {error, Reason} otherwise.
session_start(Address, Port, Timers) -> Result
Opens a new session. By default Sessions are NOT linked to the SMSC.
Timers is a timers record as declared in oserl.hrl.
Returns {ok, Session} if success, {error, Reason} otherwise.
See also: session_start/3, gen_smsc_session:start/2.
session_stop(Session) -> ok
Stops the Session.
start(Module, Args, Options) -> Result
Starts the SMSC server.
Module, Args and Options have the exact same meaning as in gen_server behavior.
See also: start/4, start_link/3, gen_server:start/3.
start(ServerName, Module, Args, Options) -> Result
Starts the SMSC server.
ServerName, Module, Args and Options have the exact same meaning as in gen_server behavior.
See also: start/3, start_link/4, gen_server:start/4.
start_link(Module, Args, Options) -> Result
Starts the SMSC server.
Module, Args and Options have the exact same meaning as in gen_server behavior.
See also: start/3, start_link/4, gen_server:start_link/3.
start_link(ServerName, Module, Args, Options) -> Result
Starts the SMSC server.
ServerName, Module, Args and Options have the exact same meaning as in gen_server behavior.
See also: start/4, start_link/3, gen_server:start_link/4.
terminate(R::Reason, S::State) -> ok
gen_server - terminate/2 callback implementation.
Shutdown the server.
Return value is ignored by gen_server.
unbind(Session) -> Result
Issues an unbind operation on the session identified by Session.