NetTalk Central

Author Topic: Final WebRequest from Client at ThisWindow.Kill  (Read 3588 times)

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Final WebRequest from Client at ThisWindow.Kill
« on: March 12, 2019, 09:15:25 AM »
Hello Bruce and all others,

my intention is to make my webclient sending a final request to the server, reporting that it is now shuting down. The webserver holds a list of active clients with Active Since / Last Activity / Idle in Minutes for the Admin to see. whether he can run the update-installer or has to phone to the user to close down.

However, when I call this liitle ROUTINE in the first embed of ThisWindow.Kill, right before WebClient.Kill, then it does not get performed. I know that this routine works okay, because I can call it successfully from a simple ?Button.

Now I could use this ?Button to mimic a ?Close, but this would not help, if the user presses that [X] in the top right corner. Same with the MainMenus E&xit.

A (likely dirty) solution would be, to prohibit ThisWindow.Kill in general and only allow it under a specific condition. That condition could be set within this ?Button, once that webrequest was done.

Does have anyone an idea, how to achieve that?

Or have an even better, since cleaner idea?

tia
Wolfgang

Jane

  • Sr. Member
  • ****
  • Posts: 355
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Final WebRequest from Client at ThisWindow.Kill
« Reply #1 on: March 12, 2019, 10:13:30 AM »
If you just want to control whether a window in a desktop app is permitted to close, Wolfgang, you can use a flag as in the attached example.

Jane

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: Final WebRequest from Client at ThisWindow.Kill
« Reply #2 on: March 12, 2019, 11:59:41 AM »
If you just want to control whether a window in a desktop app is permitted to close, Wolfgang, you can use a flag as in the attached example.

Jane

YASSS!

That did the trick!

I tried this CYCLE before, but it never worked for me, because I fiddled in the method, and anything like CYCLE or RETURN (what:ever) is not aloowed in this scoped.

LOC:CanClose is FALSE by default. Once the user now presses anything like ?Close or that [X], I call my little webrequest-routine and CYCLE. Once the request is answered be the server, either in WebClient.PageReceived or WebClient.ErrorTrap, then I switch LOC:CanClose to TRUE and POST(Event:CloseDown). Not that is is allowed to close, all options like E&xit, ?Close or that [X] work as usual.

Thank you so much, Jane!

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: Final WebRequest from Client at ThisWindow.Kill
« Reply #3 on: March 12, 2019, 09:29:50 PM »
You can't do a FETCH or POST inside KILL because comms is asynchronous. So the connection would be closed in KILL before the outgoing packet has a chance to be sent. You would need to wait for the reply to your FETCH or POST, then close the window.

cheers
Bruce