Can not get Events working

(egold2005) #1


It seems i am missing something about setting up an events, but i could not get them propagate to client.

Delphi 2007, RO

I have EventRepository property set for service, it is TROInMemoryEventRepository. EventRepository is connected to separate Channel component placed on this service, and SessionManager located in server datamodule.

LegacyEvents is set to TRUE both in service and on client side, in EventReceiver component.

Service’ SessionManager property it set to the same TROInMemorySessionManager located in Server Datamodule. There is of course DataStreamer component placed in service.

RequiresSession is set to TRUE on service, and i do Login/Logout implemented.

Now i have a service method, it is being called from client, it is lengthy operation and server should report the progress back to client during the operation. Like this

procedure TIdlsReport.SendProgress(const AProgress: integer);
   var vEV: IReportEvent_Writer;
   CodeSite.EnterMethod(Self, 'SendProgress');

   if not Assigned(FEventRepository) then exit;

   vEV := (FEventRepository as IReportEvent_Writer);
   vEV.ReportProgress(FSessionID, GuidToString(FClientReportID), AProgress);

   CodeSite.ExitMethod(Self, 'SendProgress');

TIdlsReport is a class that handles the operation, and FSessionID and EventRepository are being passed from a service method that creates instance of the class.

On client side, i have TROEventReceiver component, connected to main Channel component (i know it is better to create separate channel, tried that as well), linked to IdlsReportsService, and Interval is set to 1000.

On login i activate event receiver

   vSL := TStringList.create;

      vAuthService := CoIdlsAuthService.Create(ROMessage, ROChannel);
      if vAuthService.Login(eUsername.text, ePassword.text, vSL.CommaText, vUserInfo) then begin
         lUserInfo.caption := 'User is logged in. User ID: ' + vUserInfo.UserID;
         FUserID := strToInt(vUserInfo.UserID);

         EventReceiver.RegisterEventHandlers([EID_ReportEvent], [Self]);

         ShowMessage('login failed')


And here is the event implementation on client that is never being called for some reason

procedure TfrmIdlsROTestClientMain.OnReportProgress(const AClientReportID: TGUID; const AProgress: integer);
   ProgressBar1.Position := AProgress;
   Memo1.Lines.Add('Progress received: ' + intTostr(AProgress));

Any advice would be greatly appreciated.

Thank you.

(EvgenyK) #2

try to add ExcludeSender := False; like

(egold2005) #3

Thanks Evgeny, it did not help. I tried to add RegisterEventClient, playing with LegacyEvents (BTW what is it for) etc.

Is there a way i can email my test project so you can take a look?

(EvgenyK) #4

pls read Event Sinks and Server Callbacks. it describes difference between legacy (i.e. LegacyEvents = true) and .NET-compatible modes.

yes, you can send it to support@.

Note: these samples: HTTP Chat, SuperHTTP Chat and SuperTCP Channel Chat demonstrate usage of .NET-compatible mode.

(egold2005) #5

Thank you Evgeny, i got it working. I missed a few bits in client side implementation.

(egold2005) #6

Do i necessarily need to add to SessionList before calling?

vEV := (FEventRepository as IReportEvent_Writer);
vEV.ExcludeSender := FALSE;
vEV.ReportProgress(FSessionID, GuidToString(FClientReportID), AProgress);

(EvgenyK) #7

you should specify SessionList only if you want to send event to specific set of clients. if SessionList is empty, event will be sent to all clients.