| | |
| | | 'enable_coroutine' => true, |
| | | 'task_enable_coroutine' => true |
| | | ]); |
| | | if (!$this->redis) { |
| | | $this->redis = new Redis(); |
| | | $this->redis->connect($this->redis_config['host'],$this->redis_config['port'] ); |
| | | $host = $this->server_config['allow_ip']; |
| | | $keyList = $this->redis->keys("*{$host}*"); |
| | | foreach ($keyList as $key => $value) { |
| | | $this->redis->del($value); |
| | | $this->server->on('WorkerStart', function (Swoole\WebSocket\Server $server) { |
| | | if (!$this->redis) { |
| | | $this->redis = new Redis(); |
| | | $this->redis->connect($this->redis_config['host'],$this->redis_config['port'] ); |
| | | $host = $this->server_config['allow_ip']; |
| | | $keyList = $this->redis->keys("*{$host}*"); |
| | | foreach ($keyList as $key => $value) { |
| | | $this->redis->del($value); |
| | | } |
| | | $this->redis->del("{$host}*"); |
| | | $this->redis->close(); |
| | | } |
| | | $this->redis->del("{$host}*"); |
| | | $this->redis->close(); |
| | | } |
| | | }); |
| | | $this->server->on('start', function (Swoole\WebSocket\Server $server) { |
| | | echo "Websocket Server is started at ws://".$this->server_config['host'].":".$this->server_config['port']."\n"; |
| | | }); |