How to create a TRoRemoteDataModule that would be attached to a specific server?

Hi
I have a server application which already has a TRoIndyHttpServer with several methods, etc and this is working fine.
I would like to put a new server component (another TRoIndyHttpServer) to this application in order to implement a “admin” interface listening to another port. I know how to do that.

The problem is defining some methods that only this server would respond to.
I didn’t find any way to create a link from the service unit to just this specific server.

I’ve created this TRoRemoteDataModule:

unit Admin_Impl;

{$I RemObjects.inc}
interface

uses
  System.SysUtils, System.Classes, System.TypInfo,
  uROXMLIntf, uROClientIntf, uROClasses, uROTypes, uROServer, uROServerIntf, uROSessions,
  uRORemoteDataModule, uRORTTIAttributes, uRORTTIServerSupport, uROArray, roTypes;

const
  __ServiceName ='admin';
type
 
  [ROService(__ServiceName)]
  TAdmin = class(TRORemoteDataModule)
   
    public
      // admin methods
      [ROServiceMethod]
      function someMethod(): string;
      

  end;
  ...
  initialization
  RegisterCodeFirstService(TAdmin);
end.

What I’ve found so far is that this method (someMethod) could be executed my all the servers in this project.
Is there a way in which I could link this “interface” TAdmin with the new server component in order to allow just the clients querying at its port to run this methods?

Hi,

by default, all services are available via each server components.

some ideas:

  • using OnGetDispatchInfo event.
    you can get some info that can be used for checking. For example IROHTTPTransport.Location. See more about this event at this snippet.
  • protect your service with Roles.
    When administrator is logged, you can assign to him special role in Login method (Session.Roles := l_roles;)
    your someMethod also should be protected with special role like
      [RORole('adminrole')]
      [ROServiceMethod]
      function someMethod(): string;
1 Like