Integrate webSocket Case

Hi,

I used a 3rd-party websocket component to received websocket message and then to trigger the service accordingly.

My question is : How to I calling the service method with session required.

I checked the way to calling other serivice within current service.

function TFirstService.GetServerTime: DateTime;
var
cf: IROClassFactory;
instance: IInterface;
objactivation:IROObjectActivation;
begin
cf:=GetClassFactory(‘SecondService’);
cf.CreateInstance(ClientID, instance);

if Supports(instance, IROObjectActivation, objactivation) then
begin
objactivation.OnActivate(ClientID, nil);
end;

Result := (instance as ISecondService).GetServerTime();

if Supports(instance, IROObjectActivation, objactivation) then
begin
objactivation.OnDeactivate(ClientId);
end;

instance := nil;
end;

However, my current case is no any active service . Just like client within the server side.

Should I really create the same way as a delphi client like client channel and message etc.. ?

please advise

Hi,

you can use LocalServiceAccess_Acquire/LocalServiceAccess_Release methods like

instance := LocalServiceAccess_Acquire(ClientID, 'SecondService');
try
  Result := (instance as ISecondService).GetServerTime();
finally
  LocalServiceAccess_Release(ClientID, 'SecondService', instance);
end;

this code looks more cleaner.


also you can use Local Channel. it is designed for combining client- and server-side into one app