JQuery Chat Kick/Ban

JavaScript related questions should go here.
Post Reply
ExtremeGaming
Posts: 205
Joined: Mon Jul 09, 2012 11:13 pm

JQuery Chat Kick/Ban

Post 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.
<?php while(!$succeed = try()); ?>
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: JQuery Chat Kick/Ban

Post 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).
ExtremeGaming
Posts: 205
Joined: Mon Jul 09, 2012 11:13 pm

Re: JQuery Chat Kick/Ban

Post 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. :)
<?php while(!$succeed = try()); ?>
Post Reply