Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIWServerController: OnBeforeNewSession/OnNewSession
#4
Please open your IWServerControllerBase.hpp file. In there you will find the definition of the method type:

Code:
typedef void __fastcall (__closure *TOnBeforeNewSessionEvent)(const System::UnicodeString aUrlPath, Iw::Http::Request::THttpRequest* aRequest, /* out */ bool &vCanCreate);

As you can see the definition is correct. The event signature though is wrong once created in RAD Studio 10.2.3 (at least) and I think this is a bug in RAD Studio but I couldn't find any reference to it.

There is an easy fix though. Just manually edit the parameter to match the original method signature, in both your ServerController.cpp and ServerController.h files as:

In ServerController.cpp file:

Code:
#pragma startup setServerController
void __fastcall TIWServerController::IWServerControllerBaseBeforeNewSession(const UnicodeString aUrlPath,
  THttpRequest *aRequest, bool &vCanCreate)
{
  vCanCreate = false;
}

In ServerController.h file:

Code:
void __fastcall IWServerControllerBaseBeforeNewSession(const UnicodeString aUrlPath,

          THttpRequest *aRequest, bool &vCanCreate);

Please notice that I just added an ampersand (&) in front of vCanCreate parameter, so it is passed as reference. 

I tested it in a C++ project and it works correctly (try setting vCanCreate = false as I did above and you will receive a 404 error every time you try to create a new session). 

I'll test it in latest RAD Studio 10.4 and see if it behaves the same. Other than that, I think the only other thing I can do is report it to Embarcadero so they can fix it.

Cheers
Reply


Messages In This Thread
RE: TIWServerController: OnBeforeNewSession/OnNewSession - by Alexandre Machado - 06-11-2020, 07:01 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)