"I am Alive" in single browser session - xpages

How to stop a user from opening a new browser session in XPages
In the answer to this posting Knutt added a really nice bit of code that stops a user from opening multiple instances of the same application in a browser. This works very well in a web browser, but when the App is opened in a Notes Client the screen flashes every 5 seconds as the "I am Alive" code is executed. I have set the database in the Notes Preferences to run on server, but this does not seem to help.
Does anyone have any ideas how to, fix this?

I found a conflict between two other processes that were causing the issue. The frequency happened to be very similar to the 5 -7 seconds used in "I am Alive". It is working as intended with no code change needed.

Related

Dialogflow fulfillments timeout after 5 seconds, How can we overcome this limit?

Imagine the following scenario:
Our client starts a conversation with our bot regarding a problem with one of their websites.
We go and check the website in our backend through our fulfilment web service and if there is no obvious problem we want to then generate a screenshot of the website and present it to our client.
The screenshot could take more than 5 seconds to take as many websites take longer than 5 seconds to fully load.
As a result the response timeouts.
We can't force our clients to redesign their websites to lead faster than 5 seconds just so that our chatbot can handle their request.
I assume there are many other real-world examples in which fulfillments can take more than 5 seconds.
Example:
Client: My website www.example.com doesn't load.
Bot: I just checked the website and it loads fine for me. Here is a screenshot of your website for you to check:
{Image goes here}
The short answer is - you can't.
There are some tricks that work sometimes, but they won't work in all scenarios, and aren't good practices anyway.
Your best bet would be to respond to the user with a message saying you're doing some checks and diagnostics and to ask for an update in a moment (and, if possible, provide a Suggestion Chip prompting them to ask for it). After sending that message, launch a background task to do the checks to see what might be going on and take the screen shot. When they ask for an update, you can report with what you have (latency time, the screen shot, etc) or if things are being slow and that you're still checking.

Checking other users are viewing this page in Node Express

I have a NodeJs Express app and when a particular user goes to a page/route would like to identify and display if another user is currently viewing the page as well. So for example it would say "Jerry currently viewing this page" and someone else goes there.
Is there any easy/lightweight way to do this?
First off, with a regular web page, the server only knows who and when a page was requested. It doesn't, all by itself, know whether that user is still viewing that page or not. The user could have closed the browser, typed something else in the URL bar, the computer could have gone to sleep, etc...
Second off, even if the page is still being displayed in the browser, you can't know if someone is actually there at the computer or not. The best you could do is to try to keep track of activity in that web page (last mouse click, recent mouse movements over the web page, etc...).
Then, to even have any idea of the web page is even still open in the browser, you need some way of tracking that notion. There are two possibilities I can think of.
You can have some Javascript in the web page that regularly (say once every few minutes) sends a small little ajax call to your server that basically just says "I'm still here". This wouldn't know immediately when they left the page, but if the server finds that the usual every few minutes ajax call didn't come, then the server can change the status of that user on that page to not there any more.
If that web page makes a webSocket or socket.io connection to the server and keeps that connection alive, then whenever the browser closes or the user closed that tab or navigates to another page, that webSocket or socket.io connection will get automatically closed and the server will be notified that the socket got closed. Using this technique, the server can know pretty much right away when the user leaves the page.

Is there actually a way to open a popup on browser CLOSE?

I'm trying to launch a "logout" page if the usesr closes the browser...I've looked for a couple of days and I think I have looked at all of the related topics...tried quite a few...but so far, nothing is working the way I need it to...
Everything seems to trigger just navigating to the next page...I want to be able to navigate the site and NOTHING IF I LOG OUT...but if I CLOSE THE BROWSER (or the DOMAIN changes), I want to fire the logout page.
Actually, it really doesn't need to open a popup...but that would be my preference...
Thanks for any help in getting a definitive answer...
HOLD THE PHONE...
Just FYI...I found what seems to be working here:
[http://eureka.ykyuen.info/2011/02/22/jquery-javascript-capture-the-browser-or-tab-closed-event/][1]
...and it also seems that there are some very useful variations from contributers.
I also added a line to the original script to execute my logout page...
You should be able to add a listener using onbeforeunload and ask the user if they want to log out in the prompt https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload

Whats the standard way to detect the window close event in the browser?

Whats the standard way to detect the browser window close event in any standard browser? By standard I mean something that sites like Google or Facebook implement when the "keep me signed in" checkbox is unchecked. I have an interactive website in place where theres an Instant Messaging module and I need to inform the other user that the partner has logged out.
Thanks in advance.
The keep me signed in links are managed via cookies and cookie timeout lengths.
One approach to doing something like this is to have the browser make an async ajax call every (1 minute) to your server so you know they are still logged in. If you dont receive one of these calls within say 90 seconds you can say they are logged out.
This approach would also catch cases where for example their connection went or their computer crashed.

Submit a form in the background automatically

I want to create a Google Chrome extension that runs constantly in the background, even when Chrome windows are closed - this is what a Background Page is for, correct? Or should I be looking at something else?
Basically what I wish to do is have a setTimeout() load a page every 5 minutes and if its presented with a login page, automatically logs in with a given username and password, otherwise it does nothing.
This is simply to keep the session alive...
Is this possible to do?

Resources