Page 1 of 1

JQuery Chat Kick/Ban

Posted: Mon Apr 15, 2013 1:08 pm
by ExtremeGaming
I'm wrapping my head around a kick/ban feature for a chat I'm working on. My only question, is if I were to create a simple JavaScript function like...
function check(){

	$.ajax({
		type: "GET",
		url: "check.php",
		data: {  
			'function': 'check'
		},
		
		success: function(data){
			// Something
		}
	});

}
But actually tested... And it was called upon every second or so, to go to a php file such as...
<?php
session_start();

$data = array();
    
switch ($function) {

case ('check'):
		
	if(isset($_SESSION['banned']) && $_SESSION['banned'] == 1)
		$data[] = 1;
	else
		$data[] = 0;

        // And probably kicked here too
	
break;

}
?>
But actually tested... Would this affect the server performance. I'm not too sure what the affects would be for 100-500 people, and I would like opinions before I start development.

Re: JQuery Chat Kick/Ban

Posted: Thu Apr 18, 2013 4:32 am
by Helx
I'd imagine that's like 500 people reloading your page every second...
Maybe not the best way to go about it?

Instead, why not check if they're banned when they try to chat? And of course maybe do what you're doing now to check if they've been kicked, but at a much larger check rate (I'd advise about 5-15 seconds).

Re: JQuery Chat Kick/Ban

Posted: Wed May 01, 2013 1:05 pm
by ExtremeGaming
Ok. Thanks for your help. I'm almost done now :)

I chose 30 seconds since I'll be checking in the PHP as well, and just die with json_encode and use javascript to tell them they are banned/kicked if they are.

I've got all the functions set up, except a way to automatically ban without manually inserting into a file. So I've just got a bit more work to do with admin stuff, and finding ways to decrease the pressure on the server. :)