SimpAttributes

A wrapper class for access to attributes associated with a SiMP session (e.g. WebSocket session).

@author Rossen Stoyanchev @since 4.1

Constructors

this
this(string sessionId, Map!(string, Object) attributes)

Constructor wrapping the given session attributes map. @param sessionId the id of the associated session @param attributes the attributes

Members

Functions

getAttribute
Object getAttribute(string name)

Return the value for the attribute of the given name, if any. @param name the name of the attribute @return the current attribute value, or {@code null} if not found

getAttributeNames
string[] getAttributeNames()

Retrieve the names of all attributes. @return the attribute names as string array, never {@code null}

getSessionId
string getSessionId()

Return an id for the associated session. @return the session id as string (never {@code null})

getSessionMutex
Object getSessionMutex()

Expose the object to synchronize on for the underlying session. @return the session mutex to use (never {@code null})

isSessionCompleted
bool isSessionCompleted()

Whether the {@link #sessionCompleted()} was already invoked.

registerDestructionCallback
void registerDestructionCallback(string name, Runnable callback)

Register a callback to execute on destruction of the specified attribute. The callback is executed when the session is closed. @param name the name of the attribute to register the callback for @param callback the destruction callback to be executed

removeAttribute
void removeAttribute(string name)

Remove the attribute of the given name, if it exists. <p>Also removes the registered destruction callback for the specified attribute, if any. However it <i>does not</i> execute the callback. It is assumed the removed object will continue to be used and destroyed independently at the appropriate time. @param name the name of the attribute

sessionCompleted
void sessionCompleted()

Invoked when the session is completed. Executed completion callbacks.

setAttribute
void setAttribute(string name, Object value)

Set the value with the given name replacing an existing value (if any). @param name the name of the attribute @param value the value for the attribute

Static functions

fromMessage
SimpAttributes fromMessage(Message!T message)

Extract the SiMP session attributes from the given message and wrap them in a {@link SimpAttributes} instance. @param message the message to extract session attributes from

Variables

DESTRUCTION_CALLBACK_NAME_PREFIX
enum string DESTRUCTION_CALLBACK_NAME_PREFIX;

Prefix for the name of session attributes used to store destruction callbacks.

SESSION_COMPLETED_NAME
enum string SESSION_COMPLETED_NAME;

Key set after the session is completed.

SESSION_MUTEX_NAME
enum string SESSION_MUTEX_NAME;

Key for the mutex session attribute.

Meta