zhoudw
2021-12-21 14523c96e2aef9ab466a90f670569c1f152af696
删除key
2 files modified
11 ■■■■ changed files
config/config.php 4 ●●●● patch | view | raw | blame | history
ws_server.php 7 ●●●●● patch | view | raw | blame | history
config/config.php
@@ -2,7 +2,7 @@
/*
 * @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
@@ -15,7 +15,7 @@
    ),
    //本机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',
    ),
ws_server.php
@@ -28,6 +28,13 @@
        ]);
        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";