LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling a session in a WebVI

I'm trying to implement a 'search' function in my WebVI, interfacing with an external service to do the lookup. The external service is session based, and I'm having trouble figuring out a way to ensure my sessions are always closed cleanly.

 

My initial thought was to do a standard "initialize" before the while loop and a "cleanup" after, but I quickly realized that wouldn't work unless I had a 'stop' button and could somehow force the user to be unable to close the tab/window without first stopping the application. I can't figure out a way to do that, nor can I think of a way to do it using straight javascript, so I ruled that out. That said, I'm not a javascript wizard, so maybe there is a way that I don't realize.

 

My second thought was to do everything (open session -> do query operation -> close session) in an event structure frame, linked to the "search" button. That's closer to what I want, but i assume that if I were to close the browser in the middle of the search process, I'd still end up with an orphan session.

 

Thinking from a web-developer perspective, this seems like something one would normally do in a server-side script (e.g. PHP), so I guess I could build a LabVIEW 20xx web service that implements my search, but I was trying to avoid that.

 

So, to be clear, my questions are as follows:

  • Is there any way to detect and respond to a 'browser close event' from a WebVI (natively or via JS)?
  • Do WebVI event frames stop executing immediately when the browser is closed?
  • Is there any way of doing the equivalent of server-side scripting on the NI Web Server (in any language), other than a LabVIEW 20xx web service?

 

 

--------------------------------------
0 Kudos
Message 1 of 2
(1,851 Views)

Actually, I didn't realize JS had the onbeforeunload onunload event. That might do what I need; I'll try it out momentarily. I'd still be interested to know if there's a recommended way though.

--------------------------------------
0 Kudos
Message 2 of 2
(1,841 Views)