Interface ISessionStorage
Interface for accessing the session storage singleton
Namespace: DuetWebServer.Singletons
Assembly: DuetWebServer.dll
Syntax
public interface ISessionStorage
Methods
CacheMessage(string)
Cache an incoming generic message
Declaration
void CacheMessage(string message)
Parameters
Type | Name | Description |
---|---|---|
string | message | Message to cache |
CheckSessionKey(string, bool)
Check if the given session key provides the requested access to the given policy
Declaration
bool CheckSessionKey(string key, bool readWrite)
Parameters
Type | Name | Description |
---|---|---|
string | key | Session key |
bool | readWrite | If readWrite or readOnly policy is requested |
Returns
Type | Description |
---|---|
bool | True if access is granted |
GetCachedMessages(ClaimsPrincipal)
Retrieve the cached messages of a given user
Declaration
string GetCachedMessages(ClaimsPrincipal user)
Parameters
Type | Name | Description |
---|---|---|
ClaimsPrincipal | user |
Returns
Type | Description |
---|---|
string | Cached messages |
GetSessionId(string)
Get a session ID from the given key
Declaration
int GetSessionId(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Key to query |
Returns
Type | Description |
---|---|
int | Session ID or -1 |
GetTicketFromIpAddress(string)
Get a ticket from the given IP address
Declaration
AuthenticationTicket? GetTicketFromIpAddress(string ipAddress)
Parameters
Type | Name | Description |
---|---|---|
string | ipAddress | IP address to query |
Returns
Type | Description |
---|---|
AuthenticationTicket | Authentication ticket or null |
GetTicketFromKey(string)
Get a ticket from the given key
Declaration
AuthenticationTicket? GetTicketFromKey(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Key to query |
Returns
Type | Description |
---|---|
AuthenticationTicket | Authentication ticket or null |
MaintainSessions(TimeSpan, string)
Remove sessions that are no longer active
Declaration
void MaintainSessions(TimeSpan sessionTimeout, string socketPath)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | sessionTimeout | Timeout for HTTP sessions |
string | socketPath | API socket path |
MakeSessionKey(int, string, bool)
Make a new session key and register it if the session ID is valid
Declaration
string MakeSessionKey(int sessionId, string ipAddress, bool readWrite)
Parameters
Type | Name | Description |
---|---|---|
int | sessionId | DSF session ID |
string | ipAddress | Optional IP address to store for IP address-based authentification |
bool | readWrite | Whether the client has read-write or read-only access |
Returns
Type | Description |
---|---|
string | Authentication ticket |
MakeSessionTicket(int, string, bool)
Make a new session ticket and register it if the session ID is valid
Declaration
AuthenticationTicket MakeSessionTicket(int sessionId, string ipAddress, bool readWrite)
Parameters
Type | Name | Description |
---|---|---|
int | sessionId | DSF session ID |
string | ipAddress | Optional IP address to store for IP address-based authentification |
bool | readWrite | Whether the client has read-write or read-only access |
Returns
Type | Description |
---|---|
AuthenticationTicket | Authentication ticket |
RemoveTicket(ClaimsPrincipal)
Remove a session ticket returning the corresponding session ID
Declaration
int RemoveTicket(ClaimsPrincipal user)
Parameters
Type | Name | Description |
---|---|---|
ClaimsPrincipal | user |
Returns
Type | Description |
---|---|
int | Session ID or 0 if none was found |
SetLongRunningHttpRequest(ClaimsPrincipal, bool)
Set whether a potentially long-running HTTP request has started or finished
Declaration
void SetLongRunningHttpRequest(ClaimsPrincipal user, bool requestStarted)
Parameters
Type | Name | Description |
---|---|---|
ClaimsPrincipal | user | Principal user |
bool | requestStarted | Whether a WebSocket is connected |
SetWebSocketState(string, bool)
Set whether a given socket is connected over WebSocket
Declaration
void SetWebSocketState(string key, bool webSocketConnected)
Parameters
Type | Name | Description |
---|---|---|
string | key | Session key |
bool | webSocketConnected | Whether a WebSocket is connected |