Disconnect handling

I was wondering if there is a way to have my application redirect the browser to a different page instead of displaying App.DisconnectMessage?

I guess I could put in a listener into the app.HTMLHeader? I am not good at javascript, can someone help me out?

Set the Session.TimeOut property and in the Session TimedOut event :

ShowURL("http://mysite.com/mypage.html")

That didn’t work, I ran the server, loaded the page, quit the server, still just got “The application has gone off-line. Please try again later.”.

Anything put in the Session.TimeOut method probably will never get called unless your plan is to get code executed server side.

Oh. You mean the message that you get when the app is stopped ? “The application has gone off line” ?
But why would you stop the app outright ?

I tried to place a showurl in session close, does not work.Maybe you want to wait until the user has ended his session before killing the app. Otherwise, I do not know what else to try.

Maybe Greg will be able to assist…

Sometimes I do updates, I would like the app to take the user to a new page when I quit the server.

This may help :
https://forum.xojo.com/15427-display-dialog-on-all-sessions

Yeah I could do a showUrl on all active sessions, but for now I just want the app to redirect on disconnect.

I can see in xojo’s famework.js it shows a “preventInteraction” method which executes when the server is quit, is there any way to add a piece of javascript to this framework to do something like window.location = “newpage.html”; ?

[quote=132310:@Tyler Durden]Yeah I could do a showUrl on all active sessions, but for now I just want the app to redirect on disconnect.

I can see in xojo’s famework.js it shows a “preventInteraction” method which executes when the server is quit, is there any way to add a piece of javascript to this framework to do something like window.location = “newpage.html”; ?[/quote]

Greg O’LOne has many times warned against hacking the framework. Though what you describe seems the good syntax you would need to experiment to find the proper place to do it. There are several methods :
http://ntt.cc/2008/01/21/5-ways-to-redirect-url-with-javascript.html

There is another way, outlined in Phillip Zedalis from 1701software.com in his blog post :
http://1701software.com/blog/upgrading_xojo_cgi_apps.php

He describes the method for cgi, but it works fine for standalone as well :

Monitor in a timer if the app executable is still here. If the file does not exist, then the app quits all sessions so it can be upgraded.

What you could do is kind of the same thing, except that you do not stop the app, you delete the executable, and when the app finds out, it cleanly quits, and before it does, it takes users to an HTML page.

I found a better way, it probably sucks but it works. I noticed that when the app quits, the framework executes this:

setTimeout("document.getElementById('XojoDisconnect').style.top = '0%'",10);
so I put this into my App’s HTMLHeader:

<script> function isstillrunning(){ var xd = document.getElementById('XojoDisconnect'); if(xd){ if(xd.style.top=='0%'){ window.location.assign("http://www.xojo.com/") } } setTimeout(isstillrunning, 1000); } isstillrunning(); </script>

If anyone knows of a nicer way of doing this let me know…

If you open the docs for the WebSDK, we fire an event just before showing the disconnected overlay on the XojoSession element (Section 6, Page 22). If you listen for the event, you can redirect to another page, something like this:

Xojo.addListener("XojoSession", "disconnect", function() { document.location='http://www.example.com'; } );

You’ll want to use the WebSDK so the SDK methods get added to the page, and then make sure you use Xojo.addListener instead of document.addEventListener because our framework has automatic fallback for IE and browsers that don’t support custom events.

[quote=132301:@Michel Bujardet]Oh. You mean the message that you get when the app is stopped ? “The application has gone off line” ?
But why would you stop the app outright ?[/quote]
One reason I found out the hard way was the database, MySQL, had stopped. When I tried to connect the application crashed, which is not good. So after the error message I ‘quit’ the Session.

I had a OS X and server update that went bad; I did not know it was bad at the time.

It sounds like you got a databaseException. Perhaps the better solution is to handle them more gracefully?