unit uROMasterServerEventRepository; {----------------------------------------------------------------------------} { RemObjects SDK Library - Core Library } { } { compiler: Delphi 5 and up, Kylix 2 and up } { platform: Win32, Linux } { } { (c)opyright RemObjects Software. all rights reserved. } { } { Using this code requires a valid license of the RemObjects SDK } { which can be obtained at http://www.remobjects.com. } {----------------------------------------------------------------------------} {$I RemObjects.inc} interface uses Classes, uROEventRepository, uROClientIntf, uROClient, uROTypes, ROMasterServerLibrary_Intf; type { TROMasterServerEventRepository } TROMasterServerEventRepository = class(TROEventRepository) private fChannel: TROTransportChannel; fSessionManager : IROSessionManager; procedure SetChannel(const Value: TROTransportChannel); function GetSessionManager: IROSessionManager; protected procedure Notification(aComponent: TComponent; Operation: TOperation); override; { Overrides } procedure DoStoreEventData(SourceSessionID : TGUID; Data : Binary; const ExcludeSender: Boolean; const ExcludeSessionList: Boolean; const SessionList: String); override; function DoGetEventData(SessionID : TGUID; var TargetStream : Binary) : integer; override; procedure DoAddSession(aSessionID : TGUID); override; procedure DoRemoveSession(aSessionID : TGUID); override; public constructor Create(aOwner : TComponent); override; destructor Destroy; override; procedure CheckProperties; override; property SessionManager : IROSessionManager read GetSessionManager; published property Channel : TROTransportChannel read fChannel write SetChannel; end; implementation uses SysUtils, uROClasses; { TROMasterServerEventRepository } procedure TROMasterServerEventRepository.CheckProperties; begin Check(Channel = nil, Name + '.Channel must be assigned.'); Channel.CheckProperties; inherited; end; constructor TROMasterServerEventRepository.Create(aOwner: TComponent); begin inherited; end; destructor TROMasterServerEventRepository.Destroy; begin inherited; end; procedure TROMasterServerEventRepository.DoAddSession(aSessionID: TGUID); begin SessionManager.CreateSession(GUIDToString(aSessionID), NIL); end; function TROMasterServerEventRepository.DoGetEventData(SessionID: TGUID; var TargetStream: Binary): integer; begin result := SessionManager.GetMessages(GUIDToString(SessionID), TargetStream); TargetStream.Position := 0; end; procedure TROMasterServerEventRepository.DoRemoveSession( aSessionID: TGUID); begin SessionManager.DeleteSession(GUIDToString(aSessionID)); end; procedure TROMasterServerEventRepository.DoStoreEventData(SourceSessionID : TGUID; Data : Binary; const ExcludeSender: Boolean; const ExcludeSessionList: Boolean; const SessionList: String); begin SessionManager.StoreMessage(GUIDToString(SourceSessionID), Data, ExcludeSender, ExcludeSessionList, SessionList) end; function TROMasterServerEventRepository.GetSessionManager: IROSessionManager; begin CheckProperties; if (fSessionManager=NIL) then begin fSessionManager := CoROSessionManager.Create(Message, Channel); end; result := fSessionManager; end; procedure TROMasterServerEventRepository.Notification( aComponent: TComponent; Operation: TOperation); begin inherited; if (Operation<>opRemove) then Exit; if (aComponent=fChannel) then fChannel := NIL; end; procedure TROMasterServerEventRepository.SetChannel( const Value: TROTransportChannel); begin if (fChannel=Value) then Exit; fChannel := Value; if (fChannel<>NIL) then fChannel.FreeNotification(Self); end; end.