How does the websocket server written by swoole restrict the flow of a client?

  node.js, question

For example, a client has been sending me spam ddos messages after connecting to my websocket server. I want to set that client to send messages to the websocket server only once in 10 seconds. How to do this? Is this implemented in code in server-side scripts written by swoole or is it prevented at other levels?

Previously, similar functions were performed according to the atomic characteristics of memcache.

$microtime = microtime(true);
 //Error will be reported if it is sent twice within 10 microseconds. The minimum accuracy is 10 microseconds. The interval can be increased, for example, if it is set to 100 microseconds, it will be changed to $ microtime = substr ($ microtime, 0,-2);
 $microtime = substr($microtime,0,-1);
 $key = "safe_{$microtime}";
 $memcached = new Memcached;
 $memcached->addServer(
 "127.0.0.1","11211",1
 );
 if (!  $memcached->add($key, 1, 1)) {
 Exit ("illegal request");
 bracket

I hope it will help you.