Server onConnect

I need trace the mobile clients which connect to my RemoteDB server.
In the Connect procedure client side, I have a device S/N which I'd like pass to server side
and find as parameter in a onConnect event... for log purposes.
Is it possible achieve such kind of result tweaking Sparkle in some way ?


Hello Marco,

You can use a code like this:

Uses RemoteDB.Server.Wrappers, Sparkle.HttpServer.Context
  THackRemoteDBModule = class(TRemoteDBModule)
  THackRemoteDBModule(Module).OnDBRetrieved := procedure(DB: TRemoteDatabase; C: THttpServerContext)
      FD: TFDConnection;
      CustomValue: string;
      FD := (DB.Connection as IDBConnectionAdapter).AdaptedConnection as TFDConnection;
      CustomValue := C.Request.Headers.GetValue('custom-header');

Then adapt for your needs. 
Wagner R. Landgraf2019-01-22 11:18:16

Thank you Wagner !
it works enough.
The event is fired multiple times per connection, so I'll try to filter in some way;
Is there an event which fire only once per connection ?


Then you can use directly in the connection factory. But it would be safer if you use the OnDbRetrieved event. In future versions RemoteDB might use a connection pool so that the same connection can be used by different clients.

Is there any issue with using the current approach?
Ok understood.
At the moment no issue with this approach; I can tell you later, after more field tests.

Thank you.