vali 6 éve
szülő
commit
a1d68edf72

+ 51 - 75
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -22,6 +22,7 @@
 use \GatewayWorker\Lib\Gateway;
 use Workerman\Lib\Timer;
 
+
 /**
  * 主逻辑
  * 主要是处理 onConnect onMessage onClose 三个方法
@@ -34,88 +35,21 @@ class Events
      */
     public static $db = null;
     public static $global = null;
+    public static $redis = null;
+    public static $logic = null;
 
     /**
      * 进程启动后初始化数据库连接
      */
     public static function onWorkerStart($worker)
     {
+        include_once(__DIR__ . DIRECTORY_SEPARATOR . "Mlogic.php");
+        self::$logic = Mlogic::GetInstance();
+        self::$db = self::$logic->getDb();
+        self::$redis = self::$logic->getRedis();
+        self::$global = self::$logic->getGlbData();
 
-        if (empty(self::$global)) {
-            self::$global = new \GlobalData\Client('127.0.0.1:2207');
-            // 客服列表
-            if (is_null(self::$global->kfList)) {
-                self::$global->kfList = [];
-            }
-            // 会员列表[动态的,这里面只是目前未被分配的会员信息]
-            if (is_null(self::$global->userList)) {
-                self::$global->userList = [];
-            }
-            // 会员以 uid 为key的信息简表,只有在用户退出的时候,才去执行修改
-            if (is_null(self::$global->uidSimpleList)) {
-                self::$global->uidSimpleList = [];
-            }
-            // 当天的累积接入值
-            $key = date('Ymd') . 'total_in';
-            if (is_null(self::$global->$key)) {
-                self::$global->$key = 0;
-
-                $oldKey = date('Ymd', strtotime('-1 day')); // 删除前一天的统计值
-                unset(self::$global->$oldKey);
-                unset($oldKey, $key);
-            }
-            // 成功接入值
-            $key = date('Ymd') . 'success_in';
-            if (is_null(self::$global->$key)) {
-                self::$global->$key = 0;
-
-                $oldKey = date('Ymd', strtotime('-1 day')); // 删除前一天的统计值
-                unset(self::$global->$oldKey);
-                unset($oldKey, $key);
-            }
-        }
-
-        // 定时统计数据
-        if (0 == $worker->id) {
-
-            self::writeLogKfStatus(0, 0, 0);
-
-            // 1分钟统计一次实时数据
-            Timer::add(60 * 1, function () {
-                self::writeLog(1);
-            });
-            // 40分钟写一次当前日期点数的log数据
-            Timer::add(60 * 40, function () {
-                self::writeLog(2);
-            });
-
-            //每1分钟发一次本组排队数
-            Timer::add(60 * 1, function () {
-                self::lineup();
-            });
-
-            //初始化.....
-            self::upsystemconfig();
-            //每5分钟更新一次系统配置文件
-            Timer::add(60 * 3, function () {
-                self::upsystemconfig();
-            });
-
-            // 检查对话时效给出.
-            Timer::add(6, function () {
-                self::overTime();
-            });
-
-            // 实时监控.
-            Timer::add(60, function () {
-                $adminList = self::$global->adminList ?? [];
-                if ($adminList) {
-                    self::systemMonitoring($adminList);
-                }
-            });
-
-            self::resetServiceLog();
-        }
+        self::TimerThing($worker);
 
     }
 
@@ -798,4 +732,46 @@ class Events
     }
 
 
+    //定时器相关
+    private static function TimerThing($worker)
+    {
+
+        // 当天的累积接入值
+        $key = date('Ymd') . 'total_in';
+        if (is_null(self::$global->$key)) {
+            self::$global->$key = 0;
+            $oldKey = date('Ymd', strtotime('-1 day')); // 删除前一天的统计值
+            unset(self::$global->$oldKey);
+            unset($oldKey, $key);
+        }
+        // 成功接入值
+        $key = date('Ymd') . 'success_in';
+        if (is_null(self::$global->$key)) {
+            self::$global->$key = 0;
+            $oldKey = date('Ymd', strtotime('-1 day')); // 删除前一天的统计值
+            unset(self::$global->$oldKey);
+            unset($oldKey, $key);
+        }
+
+
+        // 定时统计数据
+        if (0 == $worker->id) {
+
+            self::writeLogKfStatus(0, 0, 0);
+
+            //初始化.....
+            self::upsystemconfig();
+            //每5分钟更新一次系统配置文件
+            Timer::add(60 * 3, function () {
+                self::upsystemconfig();
+            });
+
+
+            self::resetServiceLog();
+        }
+
+    }
+
+
+
 }