Class SessionTimerOptions
- java.lang.Object
-
- com.opencloud.javax.sip.sessiontimer.SessionTimerOptions
-
- All Implemented Interfaces:
Serializable
public class SessionTimerOptions extends Object implements Serializable
SessionTimerOptions values are used to specify what, if any, session timer options are to be applied to a SIP dialog.To create a dialog activity that uses a session timer, the dialog must be created using
OCSleeSipProvider.newDialogBuilder()
andDialogBuilder.withSessionTimer(SessionTimerOptions)
. For example:OCSleeSipProvider provider = getProvider(); SessionTimerOptions timerOptions = SessionTimerOptions.builder(300).build(); DialogActivity dialog = provider.newDialogBuilder() .outgoing(fromAddress, toAddress) .withSessionTimer(timerOptions) .newDialog();
SessionTimerOptions values
SessionTimerOptions values are immutable and are created using the builder pattern to make it simpler to specify optional parameters.
New values must have a session interval parameter. This parameter is passed tobuilder(int)
when creating a builder so that clients must always specify the session interval. The session interval cannot be less than 90s.
Once the builder instance is created, clients may specify the optional Min-SE and refresher values usingSessionTimerOptions.Builder.minSE(int)
andSessionTimerOptions.Builder.refresher(Refresher)
. FinallySessionTimerOptions.Builder.build()
is called to create theSessionTimerOptions
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.
Proxy Mode
If an application does not want to take part in session timer negotiation and refreshes, it can instead use a session timer in "proxy mode", where the dialog observes the session interval negotiated by the endpoints on the dialog, and watches for session refreshes from either endpoint. If no session refreshes are observed within the session interval, then aSessionExpiredEvent
will be fired on the dialog activity.
Proxy mode is intended for applications like B2BUAs that may want to just pass through whatever session timer options are negotiated by the endpoints, but still be notified when a session has expired so that dialog state can be cleaned up in the event of a failure.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SessionTimerOptions.Builder
BuildsSessionTimerOptions
values.
-
Field Summary
Fields Modifier and Type Field Description static int
LOWEST_MIN_SE
The lowest permitted session expires value, 90s.static SessionTimerOptions
NONE
A specialSessionTimerOptions
value indicating that no session timer will be used on a dialog.static SessionTimerOptions
PROXY
A specialSessionTimerOptions
value indicating that a dialog should use session timers in "proxy mode".
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SessionTimerOptions.Builder
builder(int sessionInterval)
Create a new builder ofSessionTimerOptions
values.boolean
equals(Object obj)
static SessionTimerOptions
fromBytes(byte[] in)
Efficiently read a value from a byte arraystatic SessionTimerOptions
fromMessage(javax.sip.message.Message message, boolean incoming)
Utility method to extract session timer options from headers in a SIP messagestatic SessionTimerOptions
fromStream(DataInput in)
Efficiently read a value from a streamint
getMinSE()
Get the configured minimum session expiry interval, or 0 if not specifiedint
getMinSEOrDefault(int defaultMinSE)
Get the configured minimum session expiry interval, or a default value if not specifiedRefresher
getRefresher()
Get the configured refresher, orRefresher.NONE
if not specifiedRefresher
getRefresherOrDefault(Refresher defaultRefresher)
Get the configured refresher, or a default value if not specifiedint
getSessionInterval()
Get the configured session expiry intervalint
hashCode()
boolean
hasMinSE()
Determine if thisSessionTimerOptions
value specified a minimum session expiry interval (Min-SE).boolean
hasRefresher()
Determine if thisSessionTimerOptions
value specified a refresher.boolean
hasSessionTimer()
Determine if theseSessionTimerOptions
are requesting a session timer.boolean
isNone()
Return true if this value isNONE
boolean
isProxy()
Return true if this value isPROXY
byte[]
toBytes()
Efficiently write this value to a byte arrayvoid
toStream(DataOutput out)
Efficiently write this value to a streamString
toString()
SessionTimerOptions
updateFrom422(javax.sip.message.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)
-
-
-
Field Detail
-
NONE
public static final SessionTimerOptions NONE
A specialSessionTimerOptions
value indicating that no session timer will be used on a dialog.
-
PROXY
public static final SessionTimerOptions PROXY
A specialSessionTimerOptions
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.
-
LOWEST_MIN_SE
public static final int LOWEST_MIN_SE
The lowest permitted session expires value, 90s.- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static SessionTimerOptions.Builder builder(int sessionInterval)
Create a new builder ofSessionTimerOptions
values. Callers must specify a sessionInterval value.- Parameters:
sessionInterval
- the session expiry interval in seconds.- Returns:
- a new
SessionTimerOptions.Builder
, with which further parameters may be specified, before finally callingSessionTimerOptions.Builder.build()
-
hasSessionTimer
public boolean hasSessionTimer()
Determine if theseSessionTimerOptions
are requesting a session timer. All values exceptNONE
andPROXY
request a session timer.
-
hasRefresher
public boolean hasRefresher()
Determine if thisSessionTimerOptions
value specified a refresher.- Returns:
- false if the configured refresher is
Refresher.NONE
, otherwise true
-
hasMinSE
public boolean hasMinSE()
Determine if thisSessionTimerOptions
value specified a minimum session expiry interval (Min-SE).- Returns:
- true if a Min-SE value was configured, otherwise {@link false}
-
getSessionInterval
public int getSessionInterval()
Get the configured session expiry interval
-
getMinSE
public int getMinSE()
Get the configured minimum session expiry interval, or 0 if not specified
-
getRefresher
public Refresher getRefresher()
Get the configured refresher, orRefresher.NONE
if not specified
-
isNone
public boolean isNone()
Return true if this value isNONE
-
isProxy
public boolean isProxy()
Return true if this value isPROXY
-
getMinSEOrDefault
public int getMinSEOrDefault(int defaultMinSE)
Get the configured minimum session expiry interval, or a default value if not specified- Parameters:
defaultMinSE
- the default Min-SE value in seconds, must be at leastLOWEST_MIN_SE
(90s)
-
getRefresherOrDefault
public Refresher getRefresherOrDefault(Refresher defaultRefresher)
Get the configured refresher, or a default value if not specified- Parameters:
defaultRefresher
- the default refresher, must not beRefresher.NONE
-
fromMessage
public static SessionTimerOptions fromMessage(javax.sip.message.Message message, boolean incoming)
Utility method to extract session timer options from headers in a SIP message- Parameters:
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.- Returns:
- a
SessionTimerOptions
value. This will beNONE
if the message did not contain any session timer headers.
-
toStream
public void toStream(DataOutput out) throws IOException
Efficiently write this value to a stream- Throws:
IOException
-
fromStream
public static SessionTimerOptions fromStream(DataInput in) throws IOException
Efficiently read a value from a stream- Throws:
IOException
-
toBytes
public byte[] toBytes() throws IOException
Efficiently write this value to a byte array- Throws:
IOException
-
fromBytes
public static SessionTimerOptions fromBytes(byte[] in) throws IOException
Efficiently read a value from a byte array- Throws:
IOException
-
updateFrom422
public SessionTimerOptions updateFrom422(javax.sip.message.Response response)
Update the Min-SE and Session Interval values using the Min-SE received in a 422 response. If thisSessionTimerOptions
's Min-SE value is unspecified, or lower that the Min-SE in the response, then return a newSessionTimerOptions
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.- Parameters:
response
- a 422 (Session Interval Too Small) response containing a Min-SE header.- Returns:
- a
SessionTimerOptions
instance
-
validateMinSE
public static int validateMinSE(int minSE)
-
validateSessionInterval
public static int validateSessionInterval(int se)
-
-