Command to remove/kick all users not in chat ( those that have closed their browsers)

225 views
Skip to first unread message

Chris D

unread,
Nov 15, 2014, 10:58:40 PM11/15/14
to ajax...@googlegroups.com
Curious if anyones come up with a script OR even better a command to run, that would make the chat check to see if the user's session is still active or if they've simply closed their clients. Or make it so the cookies expire or delete upon closing the browser window?


This way users wouldn't have to wait 20-40-400 minutes to verify they're not going insane from talking to someone that's not even there and just waiting to time out the next time someone logs in lol.

I have people that idle in my chat and don't close the window, so we use the /afk status, so the idle time out doesn't work to well for that/inactive setting. So was curious if anyone had a fix for this. 


Any assistance appreciated.

Chris D

unread,
Jan 6, 2015, 2:18:38 AM1/6/15
to ajax...@googlegroups.com
Bump

Kevin Ingwersen (Ingwie Phoenix)

unread,
Jan 6, 2015, 10:55:13 AM1/6/15
to Chris D, ajax...@googlegroups.com
Edit AJAXChat.php to add the functionality to store a timestamp into the ajax_chat_online_users table. Then when you add your command, run a check along all the timers and determine the time distance between the moment the command is ran and the time of the currently checked timestamp; it should be a loop. Then just run the function to kick these users.

The problem with this method or this feature request in total is, that its hard to keep a proper list of user activity and see who is still there, since you cant check if their browsers are closed or not; you can only meassure the last time they issued a requet towards the chat...

Am 06.01.2015 um 08:18 schrieb Chris D <dods...@gmail.com>:

Bump

--
You received this message because you are subscribed to the Google Groups "AJAX-chat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ajax-chat+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ingrid Sedé

unread,
Jan 7, 2015, 2:09:46 AM1/7/15
to ajax...@googlegroups.com
You can put this on the LoggedIn.html.

<script>
  window.onbeforeunload = LogUserOut;
               function LogUserOut(){
                ajaxChat.logout();
               return null;
</script>

hcfwesker6991

unread,
Jan 7, 2015, 10:56:34 PM1/7/15
to ajax...@googlegroups.com
where would you add that?  between the head or bodt tags, or after the body tag by itself?

Ingrid Sedé

unread,
Jan 8, 2015, 11:32:09 PM1/8/15
to ajax...@googlegroups.com
Right before </head> should do it.

Chris D

unread,
Jan 9, 2015, 4:16:36 PM1/9/15
to ajax...@googlegroups.com
Oh thanks for that, tested it earlier and on a few browsers but doesn't seem to work. Also tried closing the browser as a whole and still nothing. Appreciate it though, anything else I might be able to test?

Ingrid Sedé

unread,
Jan 9, 2015, 6:10:58 PM1/9/15
to ajax...@googlegroups.com
Hm, ok. Tested it here with Chrome and Firefox on Linux and it works just fine. In Opera it doesn't work.

Chris D

unread,
Jan 9, 2015, 11:49:17 PM1/9/15
to
I don't doubt you one bit lol.

Using Chrome/Firefox here. Tried removing a few scripts to see if there was interference but doesn't seem to be the case. I do notice now that regardless of where in the header I put the script that if I login on a sep browser the chat bot displays  "Chatbot: /login name"   vs "Chatbot: name has logged in"

Chris D

unread,
Jan 13, 2015, 6:59:12 PM1/13/15
to ajax...@googlegroups.com
No? Anyone else have an idea?

Appreciate your attempt Ingrid, hopefully you weren't offended that it did not work on my end, I thought it might be a conflict of something and removed others but didn't change anything, if you'd like to email me or have me send you my config I'd be grateful, or at least if you have any idea about why chatbot is stating its own commands.

jonnyboy

unread,
Jan 17, 2015, 2:28:15 AM1/17/15
to ajax...@googlegroups.com
I think it is just missing the closing }. So like this:

Kevin Ingwersen (Ingwie Phoenix)

unread,
Jan 17, 2015, 4:29:23 AM1/17/15
to jonnyboy, ajax...@googlegroups.com
Hey guys. Take a look here: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers.onbeforeunload

You should know, that ajaxChat.logout(); issues an AJAX request, which is asynchronous. Which means, that the browser may cancel this request due to closing already. It is not confirmed, but possible. 

Those who have tested this code, should report on which browsers they tested it, too.

Ingrid Sedé

unread,
Jan 17, 2015, 4:54:30 AM1/17/15
to ajax...@googlegroups.com, jonn...@jbmatrix.net
In IE10 on W7 it causes a prompt coming up asking wether you want to leave or stay on the page whenever you click an anchor tag.
This is also the case when you hit a anchor tag with javascript:url .

Chris D

unread,
Jan 19, 2015, 8:02:31 PM1/19/15
to ajax...@googlegroups.com, jonn...@jbmatrix.net
So after adding the closed bracket, code still does not work HOWEVER I do notice that if anyone refreshes now in chat including me it AUTO logs out as the code intends, which is odd since its just a refresh NOT closing the tab/window.

Anywhoo tested on latest chrome and a few versions of chrome + firefox and no avail.

Chris D

unread,
Feb 6, 2015, 12:28:08 PM2/6/15
to ajax...@googlegroups.com, jonn...@jbmatrix.net
Bumping for alternative suggestions/approaches or further guidance on the previous.

Chris D

unread,
Feb 19, 2015, 8:08:17 PM2/19/15
to ajax...@googlegroups.com, jonn...@jbmatrix.net
Bump

Frug

unread,
Feb 22, 2015, 8:40:44 PM2/22/15
to ajax...@googlegroups.com, jonn...@jbmatrix.net
Now you see why this isn't built into chat. 

Miker R

unread,
Jul 27, 2015, 12:41:09 PM7/27/15
to AJAX-chat, jonn...@jbmatrix.net, fru...@gmail.com
Okay, I get that, But I added SYN's chat view to a portal block, and if you Don't Click log-out your shown in the chat forever... at least 24 hrs as I did it yesterday, and checked today and it said I was still in the chat... So is there a way that when the "time-out" is reached, that's set in config it will basically send it through the log-out routine???

Running SMF 2.0,10, And I believe I have v0.9 (the one from GIT)

Also Is there a different way to add the pop-up function, I use Menu Editor Lite, So what it would need to do is link to a script, php, html, java, whatever Do the commands for the pop out window then load the chat??

Sry not very good at this type of coding, I did find the Info on Pop-Out but couldn't figure how to Adapt it to a Link from the Menu....Menu Editor Lite won't let you add Stuff like the Java script code that was shown....

Any Help Appreciated,

Mike

Miker R

unread,
Dec 3, 2015, 5:33:36 PM12/3/15
to AJAX-chat
FINALLY!!!

Only thing I don't like is it triggers the Browsers Leave Page....This will clear the user if he just closes the window, and Works on cross browsers (Like FireFox), But reported doesn't work on Mobules, Like UcBrowser, Opera, Etc, Haven't tried...

Let Me know if this Helped, as you can see my last post on the Was July 27th, Shows How long I've been Knocking my Head against a Wall!!

in loggedIn.html

<script type="text/javascript">
var app = {};
app.unloaded = false;
app.unload = function LogUserOut() {
    if (app.unloaded) return; else app.unloaded = true;   
            ajaxChat.logout();
    return "YO";
};
</script>

</head>

<body onunload="return app.unload();" onbeforeunload="return app.unload();">
YO
Reply all
Reply to author
Forward
0 new messages