View Source SMPPEX.ESME.Sync (smppex v3.2.1)

SMPPEX.ESME.Sync is an ESME implementation of SMPPEX.Session. It allows to send PDUs to SMSCs in a syncronous way, i.e. blocking till the response PDU comes.

One can use with SMPPEX.ESME.Sync all methods provided by SMPPEX.Session like SMPPEX.Session.send_pdu/2, etc.

Link to this section Summary

Functions

A nonblocking version of wait_for_pdus/2.

Syncronously sends a PDU and wait for at most timeout ms for a response PDU.

Stops ESME.

Syncronously wait for incoming PDUs. If the ESME already have some received PDUs, they are returned immediately.

Link to this section Types

@type awaited() ::
  {:pdu, pdu :: SMPPEX.Pdu.t()}
  | {:resp, resp_pdu :: SMPPEX.Pdu.t(), original_pdu :: SMPPEX.Pdu.t()}
  | {:timeout, pdu :: SMPPEX.Pdu.t()}
  | {:error, pdu :: SMPPEX.Pdu.t(), reason :: any()}

Link to this section Functions

Link to this function

pdus(esme, timeout \\ 5000)

View Source
@spec pdus(esme :: pid(), timeout()) :: [awaited()]

A nonblocking version of wait_for_pdus/2.

The difference is that it always immediately returns a list of items(maybe empty) and never returns :timeout or :stop.

Link to this function

request(esme, pdu, timeout \\ 5000)

View Source
@spec request(esme :: pid(), pdu :: SMPPEX.Pdu.t(), timeout :: non_neg_integer()) ::
  {:ok, resp :: SMPPEX.Pdu.t()} | :timeout | :stop | {:error, reason :: term()}

Syncronously sends a PDU and wait for at most timeout ms for a response PDU.

The default timeout is 5000 ms.

The result value is one of:

  • {:ok, resp}, where resp is a successfully received response PDU;
  • :timeout if the response PDU was not received within timeout;
  • :stop if the ESME stopped while a response was awaited;
  • {:error, reason} if the request failed.
Link to this function

start_link(host, port, opts \\ [])

View Source
@spec start_link(host :: term(), port :: non_neg_integer(), opts :: Keyword.t()) ::
  GenServer.on_start()

Starts SMPPEX.ESME.Sync.

opts is a keyword list of SMPPEX.ESME options which is directly passed to the underlying SMPPEX.ESME.start_link/4 call.

@spec stop(esme :: pid()) :: :ok

Stops ESME.

Link to this function

wait_for_pdus(esme, timeout \\ 5000)

View Source
@spec wait_for_pdus(esme :: pid(), timeout :: non_neg_integer()) ::
  [awaited()] | :timeout | :stop

Syncronously wait for incoming PDUs. If the ESME already have some received PDUs, they are returned immediately.

The default timeout is 5000 ms.

The result value is :timeout, :stop or a list of the following items:

  • {:pdu, pdu}, where pdu is an incoming PDU;
  • {:resp, resp_pdu, original_pdu} where resp_pdu is an incoming reply for a previously sent original_pdu;
  • {:timeout, pdu} for pdu's which have not received a response within ESME timeout;
  • {:error, pdu, reason} for outcoming PDUs which were not successfully sent due to reason;
  • {:ok, pdu} for outcoming PDUs which were successfully sent.

:timeout returned value indicates that the ESME didn't receive any PDUs within timeout. :stop value indicates that the ESME stopped while waiting for incoming PDUs.