| | |
| | | /* |
| | | * @Author: your name |
| | | * @Date: 2021-12-15 11:33:00 |
| | | * @LastEditTime: 2021-12-21 13:40:02 |
| | | * @LastEditTime: 2021-12-21 14:23:49 |
| | | * @LastEditors: Please set LastEditors |
| | | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | * @FilePath: /websocket/config/config.php |
| | |
| | | ), |
| | | //本机WebSocket服务配置 |
| | | 'server_config' => array( |
| | | 'allow_ip' => '120.25.156.26:58003', |
| | | 'allow_ip' => '120.25.156.26:58004', |
| | | 'host' => '0.0.0.0', |
| | | 'port' => '9501', |
| | | ), |
| | |
| | | ]); |
| | | 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->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"; |