Replaced notion of session uuid by session id which is more generic (could be a uuid, or something else).
Use STRING_TABLE for the implementation of session data container. Added a few missing comments.
This commit is contained in:
@@ -7,26 +7,43 @@ note
|
||||
deferred class
|
||||
WSF_SESSION
|
||||
|
||||
feature -- Access
|
||||
feature -- Access
|
||||
|
||||
id: READABLE_STRING_8
|
||||
-- Session identifier.
|
||||
deferred
|
||||
end
|
||||
|
||||
uuid: READABLE_STRING_8
|
||||
obsolete
|
||||
"Use `id' which is more general [2014-03]"
|
||||
deferred
|
||||
end
|
||||
|
||||
data: WSF_SESSION_DATA
|
||||
-- Data associated with current session.
|
||||
deferred
|
||||
end
|
||||
|
||||
expiration: detachable DATE_TIME
|
||||
-- Expiration date for current session, if any.
|
||||
deferred
|
||||
end
|
||||
|
||||
expired: BOOLEAN
|
||||
-- Is current session expired now?
|
||||
do
|
||||
Result := expired_at (create {DATE_TIME}.make_now_utc)
|
||||
end
|
||||
|
||||
expired_at (dt: DATE_TIME): BOOLEAN
|
||||
-- Is current session expired at date and time `dt'?
|
||||
do
|
||||
if attached expiration as e then
|
||||
Result := e < (create {DATE_TIME}.make_now_utc)
|
||||
Result := e < (dt)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- status
|
||||
|
||||
is_pending: BOOLEAN
|
||||
@@ -36,27 +53,32 @@ feature -- status
|
||||
end
|
||||
|
||||
is_destroyed: BOOLEAN
|
||||
-- Is current session in destroyed state?
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Entries
|
||||
|
||||
table: TABLE_ITERABLE [detachable ANY, READABLE_STRING_32]
|
||||
table: TABLE_ITERABLE [detachable ANY, READABLE_STRING_GENERAL]
|
||||
-- Table of session data indexed by key
|
||||
do
|
||||
Result := data
|
||||
end
|
||||
|
||||
item (k: READABLE_STRING_GENERAL): detachable ANY
|
||||
item alias "[]" (k: READABLE_STRING_GENERAL): detachable ANY assign remember
|
||||
-- Session value associated with key `k'.
|
||||
do
|
||||
Result := data.item (table_key (k))
|
||||
end
|
||||
|
||||
remember (v: detachable ANY; k: READABLE_STRING_GENERAL)
|
||||
-- Remember value `v' in association with key `k'.
|
||||
do
|
||||
data.force (v, table_key (k))
|
||||
end
|
||||
|
||||
forget (k: READABLE_STRING_GENERAL)
|
||||
-- Forget about value associated with key `k'.
|
||||
do
|
||||
data.remove (table_key (k))
|
||||
end
|
||||
@@ -71,14 +93,16 @@ feature {NONE} -- Implementation
|
||||
feature -- Control
|
||||
|
||||
destroy
|
||||
-- Destroy current session.
|
||||
deferred
|
||||
end
|
||||
|
||||
commit
|
||||
-- Commit current session, including data associated.
|
||||
deferred
|
||||
end
|
||||
|
||||
apply_to (h: HTTP_HEADER_BUILDER; req: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
|
||||
apply_to (h: HTTP_HEADER_MODIFIER; req: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
|
||||
-- Apply current session to header `h' for request `req' and optional path `a_path'.
|
||||
-- note: either use `apply_to' or `apply', not both.
|
||||
deferred
|
||||
|
||||
Reference in New Issue
Block a user