Table of Contents

Interface ISessionStorage

Namespace
DuetWebServer.Singletons
Assembly
DuetWebServer.dll

Interface for accessing the session storage singleton

public interface ISessionStorage

Methods

CacheMessage(string)

Cache an incoming generic message

void CacheMessage(string message)

Parameters

message string

Message to cache

CheckSessionKey(string, bool)

Check if the given session key provides the requested access to the given policy

bool CheckSessionKey(string key, bool readWrite)

Parameters

key string

Session key

readWrite bool

If readWrite or readOnly policy is requested

Returns

bool

True if access is granted

GetCachedMessages(ClaimsPrincipal)

Retrieve the cached messages of a given user

string GetCachedMessages(ClaimsPrincipal user)

Parameters

user ClaimsPrincipal

Returns

string

Cached messages

GetSessionId(string)

Get a session ID from the given key

int GetSessionId(string key)

Parameters

key string

Key to query

Returns

int

Session ID or -1

GetTicketFromIpAddress(string)

Get a ticket from the given IP address

AuthenticationTicket? GetTicketFromIpAddress(string ipAddress)

Parameters

ipAddress string

IP address to query

Returns

AuthenticationTicket

Authentication ticket or null

GetTicketFromKey(string)

Get a ticket from the given key

AuthenticationTicket? GetTicketFromKey(string key)

Parameters

key string

Key to query

Returns

AuthenticationTicket

Authentication ticket or null

MaintainSessions(TimeSpan, string)

Remove sessions that are no longer active

void MaintainSessions(TimeSpan sessionTimeout, string socketPath)

Parameters

sessionTimeout TimeSpan

Timeout for HTTP sessions

socketPath string

API socket path

MakeSessionKey(int, string, bool)

Make a new session key and register it if the session ID is valid

string MakeSessionKey(int sessionId, string ipAddress, bool readWrite)

Parameters

sessionId int

DSF session ID

ipAddress string

Optional IP address to store for IP address-based authentification

readWrite bool

Whether 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

AuthenticationTicket MakeSessionTicket(int sessionId, string ipAddress, bool readWrite)

Parameters

sessionId int

DSF session ID

ipAddress string

Optional IP address to store for IP address-based authentification

readWrite bool

Whether the client has read-write or read-only access

Returns

AuthenticationTicket

Authentication ticket

RemoveTicket(ClaimsPrincipal)

Remove a session ticket returning the corresponding session ID

int RemoveTicket(ClaimsPrincipal user)

Parameters

user ClaimsPrincipal

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

void SetLongRunningHttpRequest(ClaimsPrincipal user, bool requestStarted)

Parameters

user ClaimsPrincipal

Principal user

requestStarted bool

Whether a WebSocket is connected

SetWebSocketState(string, bool)

Set whether a given socket is connected over WebSocket

void SetWebSocketState(string key, bool webSocketConnected)

Parameters

key string

Session key

webSocketConnected bool

Whether a WebSocket is connected