public class SessionTimerOptions extends Object implements Serializable
To create a dialog activity that uses a session timer, the dialog must be created using
OCSleeSipProvider.newDialogBuilder()
and
DialogBuilder.withSessionTimer(SessionTimerOptions)
.
For example:
OCSleeSipProvider provider = getProvider(); SessionTimerOptions timerOptions = SessionTimerOptions.builder(300).build(); DialogActivity dialog = provider.newDialogBuilder() .outgoing(fromAddress, toAddress) .withSessionTimer(timerOptions) .newDialog();
builder(int)
when creating a builder
so that clients must always specify the session interval. The session interval cannot
be less than 90s.
SessionTimerOptions.Builder.minSE(int)
and
SessionTimerOptions.Builder.refresher(Refresher)
. Finally
SessionTimerOptions.Builder.build()
is called to create the SessionTimerOptions
instance:
SessionTimerOptions myOptions = SessionTimerOptions.builder(1800) // 1800s or 30mins session interval .minSE(300) // Min-SE is 300s or 5mins .refresher(Refresher.LOCAL) // I want to be the refresher .build();Two special SessionTimerOptions constant values are also defined:
NONE
indicates that no session timer is requested, this is the default behaviour when creating a dialog.PROXY
requests a session timer in proxy mode, see below.SessionExpiredEvent
will be fired
on the dialog activity.
Modifier and Type | Class and Description |
---|---|
static class |
SessionTimerOptions.Builder
Builds
SessionTimerOptions values. |
Modifier and Type | Field and Description |
---|---|
static int |
LOWEST_MIN_SE
The lowest permitted session expires value, 90s.
|
static SessionTimerOptions |
NONE
A special
SessionTimerOptions value indicating that no session timer will
be used on a dialog. |
static SessionTimerOptions |
PROXY
A special
SessionTimerOptions value indicating that a dialog should use
session timers in "proxy mode". |
Modifier and Type | Method and Description |
---|---|
static SessionTimerOptions.Builder |
builder(int sessionInterval)
Create a new builder of
SessionTimerOptions values. |
boolean |
equals(Object obj) |
static SessionTimerOptions |
fromBytes(byte[] in)
Efficiently read a value from a byte array
|
static SessionTimerOptions |
fromMessage(Message message,
boolean incoming)
Utility method to extract session timer options from headers in a SIP message
|
static SessionTimerOptions |
fromStream(DataInput in)
Efficiently read a value from a stream
|
int |
getMinSE()
Get the configured minimum session expiry interval, or 0 if not specified
|
int |
getMinSEOrDefault(int defaultMinSE)
Get the configured minimum session expiry interval, or a default value if not specified
|
Refresher |
getRefresher()
Get the configured refresher, or
Refresher.NONE if not specified |
Refresher |
getRefresherOrDefault(Refresher defaultRefresher)
Get the configured refresher, or a default value if not specified
|
int |
getSessionInterval()
Get the configured session expiry interval
|
int |
hashCode() |
boolean |
hasMinSE()
Determine if this
SessionTimerOptions value specified a minimum session expiry interval (Min-SE). |
boolean |
hasRefresher()
Determine if this
SessionTimerOptions value specified a refresher. |
boolean |
hasSessionTimer()
Determine if these
SessionTimerOptions are requesting a session timer. |
boolean |
isNone()
Return true if this value is
NONE |
boolean |
isProxy()
Return true if this value is
PROXY |
byte[] |
toBytes()
Efficiently write this value to a byte array
|
void |
toStream(DataOutput out)
Efficiently write this value to a stream
|
String |
toString() |
SessionTimerOptions |
updateFrom422(Response response)
Update the Min-SE and Session Interval values using the Min-SE received in a
422 response.
|
static int |
validateMinSE(int minSE) |
static int |
validateSessionInterval(int se) |
public static final SessionTimerOptions NONE
SessionTimerOptions
value indicating that no session timer will
be used on a dialog.public static final SessionTimerOptions PROXY
SessionTimerOptions
value indicating that a dialog should use
session timers in "proxy mode".In this mode, the dialog activity doesn't request its own session expiry interval or act as a refresher, but will observe any session expiry negotiated by the endpoints of the dialog, and inform the application that a session has expired if neither endpoint refreshes the dialog within the session expiry interval.
public static final int LOWEST_MIN_SE
public static SessionTimerOptions.Builder builder(int sessionInterval)
SessionTimerOptions
values. Callers must
specify a sessionInterval value.sessionInterval
- the session expiry interval in seconds.SessionTimerOptions.Builder
, with which further parameters may
be specified, before finally calling SessionTimerOptions.Builder.build()
public boolean hasSessionTimer()
SessionTimerOptions
are requesting a session timer.
All values except NONE
and PROXY
request a session timer.public boolean hasRefresher()
SessionTimerOptions
value specified a refresher.Refresher.NONE
, otherwise truepublic boolean hasMinSE()
SessionTimerOptions
value specified a minimum session expiry interval (Min-SE).false
public int getSessionInterval()
public int getMinSE()
public Refresher getRefresher()
Refresher.NONE
if not specifiedpublic boolean isNone()
NONE
public boolean isProxy()
PROXY
public int getMinSEOrDefault(int defaultMinSE)
defaultMinSE
- the default Min-SE value in seconds, must be at least LOWEST_MIN_SE
(90s)public Refresher getRefresherOrDefault(Refresher defaultRefresher)
defaultRefresher
- the default refresher, must not be Refresher.NONE
public static SessionTimerOptions fromMessage(Message message, boolean incoming)
message
- the message to be examinedincoming
- true if the message was an incoming message from the network;
otherwise false. This is necessary to determine
which party the refresher parameter is referring to.SessionTimerOptions
value. This will be NONE
if the message did not contain any session timer headers.public void toStream(DataOutput out) throws IOException
IOException
public static SessionTimerOptions fromStream(DataInput in) throws IOException
IOException
public byte[] toBytes() throws IOException
IOException
public static SessionTimerOptions fromBytes(byte[] in) throws IOException
IOException
public SessionTimerOptions updateFrom422(Response response)
SessionTimerOptions
's Min-SE value is unspecified, or lower that the Min-SE in
the response, then return a new SessionTimerOptions
with its Min-SE and
Session Interval values increased to match the response's Min-SE. If the response did
not contain a Min-SE header then there is no change.response
- a 422 (Session Interval Too Small) response containing a Min-SE header.SessionTimerOptions
instancepublic static int validateMinSE(int minSE)
public static int validateSessionInterval(int se)