Class SessionStorage
- Namespace
- DuetWebServer.Singletons
- Assembly
- DuetWebServer.dll
Storage singleton for internal HTTP sessions
public class SessionStorage : ISessionStorage
- Inheritance
-
SessionStorage
- Implements
- Inherited Members
Constructors
SessionStorage(ILogger<SessionStorage>)
Storage singleton for internal HTTP sessions
public SessionStorage(ILogger<SessionStorage> logger)
Parameters
loggerILogger<SessionStorage>Logger instance
Methods
CacheMessage(string)
Cache an incoming generic message
public void CacheMessage(string message)
Parameters
messagestringMessage to cache
CheckSessionKey(string, bool)
Check if the given session key provides the requested access to the given policy
public bool CheckSessionKey(string key, bool readWrite)
Parameters
Returns
- bool
True if access is granted
GetCachedMessages(ClaimsPrincipal)
Retrieve the cached messages of a given user
public string GetCachedMessages(ClaimsPrincipal user)
Parameters
userClaimsPrincipal
Returns
- string
Cached messages
GetSessionId(string)
Get a session ID from the given key
public int GetSessionId(string key)
Parameters
keystringKey to query
Returns
- int
Session ID or -1
GetTicketFromIpAddress(string)
Get a ticket from the given IP address
public AuthenticationTicket? GetTicketFromIpAddress(string ipAddress)
Parameters
ipAddressstringIP address to query
Returns
- AuthenticationTicket
Authentication ticket or null
GetTicketFromKey(string)
Get a ticket from the given key
public AuthenticationTicket? GetTicketFromKey(string key)
Parameters
keystringKey to query
Returns
- AuthenticationTicket
Authentication ticket or null
MaintainSessions(TimeSpan, string)
Remove sessions that are no longer active
public void MaintainSessions(TimeSpan sessionTimeout, string socketPath)
Parameters
MakeSessionKey(int, string, bool)
Make a new session key and register it if the session ID is valid
public string MakeSessionKey(int sessionId, string ipAddress, bool readWrite)
Parameters
sessionIdintDSF session ID
ipAddressstringOptional IP address if the request came from a RRF HTTP request
readWriteboolWhether the client has read-write or read-only access
Returns
- string
Authentication ticket
MakeSessionTicket(int, string, bool)
Make a new session ticket and register it if the session ID is valid
public AuthenticationTicket MakeSessionTicket(int sessionId, string ipAddress, bool readWrite)
Parameters
sessionIdintDSF session ID
ipAddressstringOptional IP address if the request came from a RRF HTTP request
readWriteboolWhether the client has read-write or read-only access
Returns
- AuthenticationTicket
Authentication ticket
RemoveTicket(ClaimsPrincipal)
Remove a session ticket returning the corresponding session ID
public int RemoveTicket(ClaimsPrincipal user)
Parameters
userClaimsPrincipal
Returns
- int
Session ID or 0 if none was found
SetLongRunningHttpRequest(ClaimsPrincipal, bool)
Set whether a potentially long-running HTTP request has started or finished
public void SetLongRunningHttpRequest(ClaimsPrincipal user, bool requestStarted)
Parameters
userClaimsPrincipalPrincipal user
requestStartedboolWhether a WebSocket is connected
SetWebSocketState(string, bool)
Set whether a given socket is connected over WebSocket
public void SetWebSocketState(string key, bool webSocketConnected)