Componentes.Terceros.RemObj.../internal/5.0.23.613/1/RemObjects SDK for Delphi/Source/uROMasterServerEventRepository.pas
david f0e35ec439 - Eliminadas las librerías para Delphi 6 (Dcu\D6) en RO y DA.
- Recompilación de RO para poner RemObjects_Core_D10 como paquete de runtime/designtime.

git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@3 b6239004-a887-0f4b-9937-50029ccdca16
2007-09-10 10:40:17 +00:00

132 lines
4.2 KiB
ObjectPascal

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.