Max Terentiev
|
|
« on: September 14, 2016, 09:46:32 PM » |
|
Hi Danijel,
It's will be nice if you add OnExecuteError event for TRtcClientModule. This event will be usefull for centralized control of Screen.Cursor, ActivityIndicator, etc. I mean this:
// disable active form, make cursor=crHourGlass, show activity indicator at start of request void __fastcall TClientDM::RtcClienModuleBeginRequest(TRtcConnection *Sender) { Screen->Cursor=crHourGlass; Screen->ActiveForm->Enabled=false; ActivityIndicator->Visible=true; }
// enable active form make cursor=crDefault, hide activity void __fastcall TClientDM::RtcClientModuleResponseDone(TRtcConnection *Sender) { Screen->Cursor=crDefault; Screen->ActiveForm->Enabled=true; ActivityIndicator->Visible=false; } //---------------------------------------------------------------------------
It's works well if we have no problem with remote function call. But if RtcClientModule.Execute fails with timeout we must enable form, change cursor, etc in catch block after every Execute call.
If you add OnExecuteError event this task can be done centralized in this event:
void __fastcall TClientDM::RtcClientModuleExecuteError(TRtcClientModule *Sender, TException *E) { Screen->Cursor=crDefault; Screen->ActiveForm->Enabled=true; ActivityIndicator->Visible=false; ShowMessage(E.Message); // optionally show error. } //---------------------------------------------------------------------------
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #1 on: September 15, 2016, 08:18:54 AM » |
|
There are actually 5 events already, which get triggered if a remote function call fails or an error occurs while processing the result:
{ This event will be called if we receave invalid response from the Server, which could mean that our Client or our Server are not up to date. } property OnResponseError:TRtcNotifyEvent read FOnResponseError write FOnResponseError;
{ This event will be called after the OnConnectLost, OnConnectFail and OnConnectError events, if the request was NOT marked for reposting. } property OnRepostCheck:TRtcNotifyEvent read FOnRepostCheck write FOnRepostCheck;
{ This event will be called after the OnRepostCheck event, if the request was not marked for reposting. If this event gets triggered, it means that there is a major problem with the server and user has to be notified about that problem and consulted about further actions. } property OnResponseAbort:TRtcNotifyEvent read FOnResponseAbort write FOnResponseAbort;
{ This event will be called after the response has been rejected by calling "Response.Reject" } property OnResponseReject:TRtcNotifyEvent read FOnResponseReject write FOnResponseReject;
{ This event will be called if an Exception is raised while (A) processing the Result received from the Server, or (B) memory can not be cleaned up afterwards. } property OnResultError:TRtcResultErrorEvent read FOnResultError write FOnResultError;
If you are using built-in RTC encryption with remote functions, also take a look at these events:
{ This event will be called if your SecretKey does not match the SecretKey specified by the ServerModule you're connecting to. On this event, you can decide not to work with that server (Response.Reject or Disconnect), or to update your SecretKey property to mirror the SercetKey of your ServerModule. } property OnEncryptWrongKey:TRtcNotifyEvent read FOnWrongEncryption write FOnWrongEncryption;
{ This event will be called if your EncryptionKey>0 and ForceEncryption=TRUE, but the Server says it does not support encryption for this ServerModule. On this event, you can decide not to work with that server (Response.Reject or Disconnect), or to set your ForceEncryption property to False and repost the request. } property OnEncryptNotSupported:TRtcNotifyEvent read FOnNoEncryption write FOnNoEncryption;
{ This event will be called if your EncryptionKey=0, but the Server wants to ForceEncryption for this ServerModule. On this event, you can decide to not work with that server (Response.Reject or Disconnect), or to activate encryption by setting the EncryptionKey. } property OnEncryptRequired:TRtcNotifyEvent read FOnNeedEncryption write FOnNeedEncryption;
In short, the OnResponseAbort event is the counterpart to the OnResponseDone event you've already mentioned. The other events mentioned above can be used to fine-tune Clients behavior in case of a communication error, wrong component configuration or version missmatch.
Best Regards, Danijel Tkalcec
|
|
|
Logged
|
|
|
|
Max Terentiev
|
|
« Reply #2 on: September 15, 2016, 10:37:01 AM » |
|
All these events NOT triggered in case of connection problems during RtcClientModule.Execute call.
For example, if we call RtcClientModule.Execute(true,2,true) and not receive any response in 2 seconds we got Error: connect timeout exception. But OnResponseAbort, OnResponseError, OnResultError, etc not triggered ! I'm try to assign all events - none of them triggered. Maybe it's works if we use RtcClientModule.Call(TrtcResult) but I sure it's NOT works for RtcClientModule.Execute;
Because of it we can't restore state of form, cursor, etc in one place, instead we must do it every time in except block after every RtcClientModule.Execute call.
So, I suggest additional event OnExecuteError OR make work any of existing events.
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #3 on: September 15, 2016, 10:55:28 AM » |
|
These events should be triggered even if you use the Execute method. If they are NOT triggering, it either means that you are using the "SkipRequests" or "DisconnectNow(True)" method, both of which would silently remove all requests from the request queue without triggering any events, or ... there is a bug in RTC - which I would need to find and fix. If you are NOT using the "SkipRequests" or the "DisconnectNow" method, then please make a short example Client and Server Project (using only RTC SDK and standard Delphi components) and send it to me by E-Mail with instructions to reproduce the issue, so I can test it locally: Best Regards, Danijel Tkalcec
|
|
|
Logged
|
|
|
|
D.Tkalcec (RTC)
|
|
« Reply #4 on: October 20, 2016, 04:27:14 PM » |
|
I've just released an update for the RTC SDK to fix the problem with "OnResponseAbort" events NOT always triggering for cancelled requests. You can download it from the "RTC SDK Downloads" area. Now, if the Execute method timed out, the "OnResponseAbort" event will be triggered when the Client Thread responsible for handling the request finishes doing whatever it was doing before the time-out.
Best Regards, Danijel Tkalcec
|
|
|
Logged
|
|
|
|
Max Terentiev
|
|
« Reply #5 on: October 20, 2016, 11:54:34 PM » |
|
Thanks for a fix ! I will test it now !
|
|
|
Logged
|
|
|
|
|