Magma Howto?
Chris Muller
afunkyobject at yahoo.com
Wed Jul 2 21:14:42 UTC 2003
Chris Muller wrote:
>> Most web applications later terminate a session after a given
>> period of inactivity. This would be an
>> appropriate time to disconnect any associated Magma sessions.
> Hm, it's shameless, but where can I find an example code snippet for a
> timeout?
One possible implementation would be to implement a method to reset the timeout
period every time you receive a request from a client. For example, you could
simply fork off a Process that terminates the session after a given period of
time:
resetTimeoutFor: aUserWebSession
(myUserSessionTimers includesKey: aUserWebSession)
ifTrue: [ (myUserSessionTimers at: aUserWebSession) terminate ].
myUserSessionTimers
at: aUserWebSession
put: (
[ (Delay for: 5 minutes) wait.
aUserWebSession terminateAndRemove ] fork).
This method could be called before or after processing any client request. The
timer that was ticking down to terminating is, itself, terminated, and a new
one begins.
You'd probably want to be sure you guarded against terminating the timer if it
was in the middle of the disconnect. Also, I don't know whether referencing
myUserSession this would actually work without block-closures, but you get the
idea.
> And editing a single article would be like
> [ mySession commit: [ self call: ArticleEditor new article: art ]]
> on: MagmaCommitError
> do: [ :e | "..." ]
Yes, to change your domain model, you enclose just the portion you want to
change in a commit block, as you did above.
> Regards, Markus
Regards,
Chris
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
More information about the Squeak-dev
mailing list
|