Today I started playing with Olympia Server for out-of-process session management. We have a RemObjects SDK service that can currently use either in-memory or in-database session state. The in-memory option is faster, but limits our pooling options.
The various session managers in RemObjects SDK are pluggable and swappable, so adding support for Olympia Server to our service was pretty straight forward. However, I quickly ran into a limitation when using Olympia Server for session management: if you make use of a custom TROSession descendant by handling CustomCreateSession (discussed here), your custom properties will not be available after they make the trip to Olympia Server and back.
After looking into the source for TROSession and TROOlympiaSessionManager, I was able to come up with a fairly simple solution that allows you to continue using a custom TROSession descendant while also making use of Olympia for out-of-process session management.
The key is to override both SaveToStream and LoadFromStream in your custom TROSession descendant. There, serialize and deserialize your custom property values using the Values name-value pair property found on TROSession.
procedure LoadFromStream(aStream: TStream; OnlyValues: Boolean = False); override; procedure SaveToStream(aStream: TStream; OnlyValues: Boolean = False); override; ... procedure TMySession.LoadFromStream(aStream: TStream; OnlyValues: Boolean); begin inherited; MyProperty := Values['MyProperty']; MyStrings.CommaText := Values['MyStrings']; end; procedure TMySession.SaveToStream(aStream: TStream; OnlyValues: Boolean); begin Values['MyProperty'] := MyProperty; Values['MyStrings'] := MyStrings.CommaText; inherited; end;
That Values property is one of the properties that will be persisted round trip with Olympia, and will allow your service to continue working as-is while making use of both a custom session class and Olympia Server.