#1 2023-06-08 18:32:17

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

transforming a legacy application to use websockets

I am trying to transform a legacy desktop application to a service based on Mormot2 and a GUI windows application
To have asynchronous communication between GUI and Service I am using websockets following the rest-websockets example in ex dir of mormot2
The problem is that this transformation happens in small steps. During this transformation I am using a TRestServerFullMemory with the method interfaces without an http server inside the legacy application
What should I use as client rest interface when creating the callback interface?
callback := TLongWorkCallback.Create(Client, ILongWorkCallback);

I am using the following:

  ImwbCallback = interface(IInvokable)
    ['{E59F752F-E961-4493-95A8-A5302CD1D857}']
    procedure LogMain(const typ:Integer; const msg:string);
  end;

  ImwbService = interface(IInvokable)
    ['{BC6964B7-3D10-4EFB-962E-45348AD71DA9}']
    procedure StartWork(const PrID: int64; const onFinish: ImwbCallback);
  end;
   
  TmwbCallback = class(TInterfacedCallback, ImwbCallback)
    protected
    procedure LogMain(const typ:Integer; const msg:string);
  end;

begin
memsrv:=TRestServerFullMemory.Create(TOrmModel.Create([],rooturl)); 
memsrv.Model.Owner:=memsrv;
memsrv.server.CreateMissingTables;
memsrv.ServiceDefine(TmwbService,[ImwbService],sicshared).ByPassAuthentication:=true;
memsrv.Resolve(ImwbService,wbService);
callback:=TmwbCallback.Create(memsrv, ImwbCallback);
wbservice.StartWork(myid,callback);

The above seems to work and I am getting callbacks, but there are cases where error is produced saying the client has been disconnected.
What can cause this "disconnection"? if the above is "illegal" what should I do to have callbacks that will work the following day when my app's transformation is finished?
Thank you in advance

Offline

#2 2023-06-09 06:41:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: transforming a legacy application to use websockets

In your code above, you don't define any client, so I don't understand how you may have any disconnection error.

Please follow the forum rules, and don't post code in the forum itself, but in a separated gist/pastebin.

Offline

#3 2023-06-10 17:08:12

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: transforming a legacy application to use websockets

ab wrote:

In your code above, you don't define any client, so I don't understand how you may have any disconnection error.

So using TRestServerFullMemory instance in TmwbCallback's creation is not the cause. I will try to debug it, to see what happens.
Thanks a lot @ab

ab wrote:

Please follow the forum rules, and don't post code in the forum itself, but in a separated gist/pastebin.

I apologize, I try not to post more that 20 lines of code before using gist.

Offline

Board footer

Powered by FluxBB