/**
* This file is part of workerman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor
* @copyright walkor
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace GatewayWorker\Lib;
use Exception;
use GatewayWorker\Protocols\GatewayProtocol;
use Workerman\Connection\TcpConnection;
/**
* 数据发送相关
*/
class Gateway
{
private $redis;
public $checkUserReadable = false;
public static function setChatRecord($from, $to, $message) {
$data = array('from' => $from, 'to' => $to, 'message' => $message, 'sent' => time());
$value = json_encode($data);
//生成json字符串
$keyName = 'rec:' . self::getRecKeyName($from, $to);
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$res = $redis -> lPush($keyName, $value);
if (!$this -> checkUserReadable) {//消息接受者无法立刻查看时,将消息设置为未读
return $redis -> hIncrBy('unread_' . $to, $from, 1);
}
return $res;
}
private static function getRecKeyName($from, $to)
{ if ($from > $to){return $to . '_' . $from;
}else{ return $from . '_' . $to;}
}
/**
* gateway 实例
*/
报错信息
Fatal error: Class 'GatewayWorker\Lib\Redis' not found in /pi/components/com_work/GatewayWorker/Lib/Gateway.php on line 49
WORKER EXIT UNEXPECTED E_ERROR Class 'GatewayWorker\Lib\Redis' not found in /pi/components/com_work/GatewayWorker/Lib/Gateway.php on line 49
worker exit with status 65280
49行就是$redis = new Redis(); 是不是不能直接使用redis.