Dus*_*sty 3 smalltalk seaside visual-age
如何显示显示所有当前海边会话及其预期到期时间的报告?
self session application sessionsDo: [:each |
html text: 'Session For ',((each properties values at: 1) username),' Expires At: '.
html render: (Time now addSeconds: (each application cache expiryPolicy timeout)).
html break].
Run Code Online (Sandbox Code Playgroud)
但是,这显示了错误的结果,因为它显示所有会话同时到期,距现在时间600秒.我找不到另一种方法来"剩余时间".
WWLD?(卢卡斯会做什么)?
KR Dusty
以下代码应该这样做:
WAApplication allInstances do: [ :application |
application keysAndHandlersDo: [ :key :session |
| policy table |
policy := application cache expiryPolicy.
table := policy instVarNamed: 'lastAccessTable'.
Transcript
show: session; show: ' expires in ';
show: policy timeout - (Time totalSeconds - (table at: key));
show: ' seconds'; cr ] ]
Run Code Online (Sandbox Code Playgroud)
请注意,上述代码访问将来可能会更改的内部数据结构.此外,您可能需要添加其他检查以使其适用于您的设置.
另请注意,您可能会获得负秒数.这意味着会话应该会消失,但还没有收到.