Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Server onConnect

 Post Reply Post Reply
Author
Rossi Marco View Drop Down
New Member
New Member
Avatar

Joined: 13 Aug 2018
Posts: 7
Post Options Post Options   Quote Rossi Marco Quote  Post ReplyReply Direct Link To This Post Topic: Server onConnect
    Posted: 21 Jan 2019 at 2:48pm
Hello,
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 ?

Regards,
Marco


Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jan 2019 at 11:15am
Hello Marco,
You can use a code like this:

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

Then adapt for your needs. 


Edited by Wagner R. Landgraf - 22 Jan 2019 at 11:18am
Back to Top
Rossi Marco View Drop Down
New Member
New Member
Avatar

Joined: 13 Aug 2018
Posts: 7
Post Options Post Options   Quote Rossi Marco Quote  Post ReplyReply Direct Link To This Post Posted: 23 Jan 2019 at 9:54am
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 ?

Regards

Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2432
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 24 Jan 2019 at 1:52am
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?
Back to Top
Rossi Marco View Drop Down
New Member
New Member
Avatar

Joined: 13 Aug 2018
Posts: 7
Post Options Post Options   Quote Rossi Marco Quote  Post ReplyReply Direct Link To This Post Posted: 27 Jan 2019 at 11:08pm
Ok understood.
At the moment no issue with this approach; I can tell you later, after more field tests.

Thank you.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down