Jump to content

How to use micro time efficiently and correctly?


Monkuar

Recommended Posts


PHP Websockets Rate limiter (Thanks to @Kicken for the help)

 

How do I setup let's say... no more than 5 requests per second?  Any idea?

 

// anti flood protection
if (isset($users[$clientID]['last_session_request'])) {
if($users[$clientID]['last_session_request'] > ''.microtime(true).'' - 1){
// users will be redirected to this page if it makes requests faster than 1 seconds
echo "Limit Reached... Simmer down!";
wsClose($clientID);
}else{
 
 
}
$users[$clientID]['last_session_request'] = microtime(true);
}

 
Edited by Monkuar
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.