Эх сурвалжийг харах

Merge branch 'dev' of http://git.bocai108.com:10180/Ethan/Customer-Service into dev

Jonlin 6 жил өмнө
parent
commit
6240e3ffdc

+ 5 - 2
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -186,7 +186,8 @@ class Events
     }
 
     // 弹出评价.
-    public static function getEvaluate($message) {
+    public static function getEvaluate($message)
+    {
         // 获取当前会话工单.
         $data = json_decode(self::$redis->HGET('SERVICELOG', $message['conversationId']), true);
         if (empty($data)) {
@@ -470,8 +471,10 @@ class Events
             $hisdata = json_decode($hisdata, true);
             $oldclientid = $hisdata['client_id'];
             self::MySendMsg($oldclientid, json_encode(['type' => 'reLoginErr', 'msg' => '相同账号登陆,本次退出'], 256));
+            self::MySendMsg($client_id, json_encode(['type' => 'reLoginErr', 'msg' => '相同账号登陆,本次退出'], 256));
             Gateway::closeClient($oldclientid);
-            sleep(1);
+            Gateway::closeCurrentClient();
+            return;
         }
 
         $onlinekf = self::getOnlineKfData($group, 1);

+ 28 - 23
vendor/GatewayWorker_windows/Applications/whisper/Mlogic.php

@@ -17,6 +17,7 @@ class Mlogic
     private static $redis = null;
     private static $redisTime = null;
     public static $global = null;
+    private static $configPath = null;
 
     public static function GetInstance()
     {
@@ -32,49 +33,53 @@ class Mlogic
 
     private static function Init()
     {
+        $mds = DIRECTORY_SEPARATOR;
+        if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
+            self::$configPath = realpath(dirname(__FILE__) . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..') . $mds . 'application' . $mds;
+        } else {
+            self::$configPath = realpath(dirname(__FILE__) . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..') . $mds . 'application' . $mds;
+        }
+
         self::getDb();
         self::getRedis();
         self::getGlbData();
     }
 
     //workman 的共享数据插件
-    public static function getGlbData()
+    public static function getGlbData($cache = 1)
     {
-        if (empty(self::$global)) {
-            self::$global = new \GlobalData\Client('127.0.0.1:2207');
+        if ($cache) {
+            if (!empty(self::$global)) {
+                return self::$global;
+            }
         }
+        self::$global = new \GlobalData\Client('127.0.0.1:2207');
         return self::$global;
     }
 
-    public static function getDb()
+    public static function getDb($cache = 1)
     {
-        if (empty(self::$db)) {
-            $mds = DIRECTORY_SEPARATOR;
-            if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
-                $dbcfg = realpath(dirname(__FILE__) . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..') . $mds . 'application' . $mds . 'database.php';
-            } else {
-                $dbcfg = realpath(dirname(__FILE__) . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..') . $mds . 'application' . $mds . 'database.php';
+        if ($cache) {
+            if (!empty(self::$db)) {
+                return self::$db;
             }
-            $conf = require($dbcfg);
-            self::$db = new \Workerman\MySQL\Connection($conf['hostname'], $conf['hostport'], $conf['username'], $conf['password'], $conf['database']);
         }
+
+        $conf = require(self::$configPath . 'database.php');
+        self::$db = new \Workerman\MySQL\Connection($conf['hostname'], $conf['hostport'], $conf['username'], $conf['password'], $conf['database']);
+
         return self::$db;
     }
 
     //实例化redis
-    public static function getRedis($force = 0)
+    public static function getRedis($cache = 1)
     {
-        if (!empty(self::$redis) && !$force) {
-            return self::$redis;
-        }
-
-        $mds = DIRECTORY_SEPARATOR;
-        if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
-            $dbcfg = realpath(dirname(__FILE__) . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..') . $mds . 'application' . $mds . 'redis.php';
-        } else {
-            $dbcfg = realpath(dirname(__FILE__) . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..' . $mds . '..') . $mds . 'application' . $mds . 'redis.php';
+        if ($cache) {
+            if (!empty(self::$redis)) {
+                return self::$redis;
+            }
         }
-        $conf = require($dbcfg);
+        $conf = require(self::$configPath . 'redis.php');
         $redis = new \Redis();
         $ret = $redis->connect($conf['host'], $conf['port']);
         if (!$ret) {