mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-04 23:35:35 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3287b96f30 | ||
|
|
00a8683658 | ||
|
|
c0ea068d04 | ||
|
|
9ba58ff90f |
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "zhamao/framework",
|
||||
"description": "high-performance intelligent assistant",
|
||||
"description": "High performance QQ robot and web server development framework",
|
||||
"minimum-stability": "stable",
|
||||
"license": "Apache-2.0",
|
||||
"version": "1.5.1",
|
||||
"version": "1.5.3",
|
||||
"authors": [
|
||||
{
|
||||
"name": "whale",
|
||||
|
||||
@@ -184,7 +184,7 @@ class Console
|
||||
$vss->callback = function(?WSConnection $conn) use ($terminal_id){
|
||||
$req = ctx()->getRequest();
|
||||
if($conn->getType() != "terminal") return false;
|
||||
if(($req->header["x-terminal-id"] ?? "") != $terminal_id || ($req->header["x-pid"] ?? "") != posix_getpid()) {
|
||||
if(($req->header["x-terminal-id"] ?? "") != $terminal_id) {
|
||||
$conn->close();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class FrameworkLoader
|
||||
"host: " . self::$settings->get("host") .
|
||||
", port: " . self::$settings->get("port") .
|
||||
", log_level: " . ZMBuf::$atomics["info_level"]->get() .
|
||||
", version: " . json_decode(file_get_contents(WORKING_DIR . "/composer.json"), true)["version"] .
|
||||
", version: " . ZM_VERSION .
|
||||
"\nworking_dir: " . DataProvider::getWorkingDir()
|
||||
);
|
||||
global $motd;
|
||||
@@ -130,6 +130,7 @@ class FrameworkLoader
|
||||
private function defineProperties() {
|
||||
define("ZM_START_TIME", microtime(true));
|
||||
define("ZM_DATA", self::$settings->get("zm_data"));
|
||||
define("ZM_VERSION", json_decode(file_get_contents(__DIR__."/../../composer.json"), true)["version"] ?? "unknown");
|
||||
define("CONFIG_DIR", self::$settings->get("config_dir"));
|
||||
define("CRASH_DIR", self::$settings->get("crash_dir"));
|
||||
@mkdir(ZM_DATA);
|
||||
|
||||
@@ -222,3 +222,5 @@ function zm_timer_tick($ms, callable $callable) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ use ZM\Annotation\Http\Middleware;
|
||||
use ZM\Annotation\Http\RequestMapping;
|
||||
use ZM\Annotation\Swoole\SwooleEventAt;
|
||||
use ZM\Connection\CQConnection;
|
||||
use ZM\ModBase;
|
||||
use ZM\Utils\ZMUtil;
|
||||
|
||||
/**
|
||||
@@ -18,7 +17,7 @@ use ZM\Utils\ZMUtil;
|
||||
* @package Module\Example
|
||||
* @since 1.0
|
||||
*/
|
||||
class Hello extends ModBase
|
||||
class Hello
|
||||
{
|
||||
/**
|
||||
* 在机器人连接后向终端输出信息
|
||||
|
||||
@@ -29,6 +29,7 @@ class ZMWebSocket
|
||||
Console::warning("ZMRequest: url must contains scheme such as \"ws(s)://\"");
|
||||
return;
|
||||
}
|
||||
if (!isset($this->parse["path"])) $this->parse["path"] = "/";
|
||||
$port = $this->parse["port"] ?? (($this->parse["scheme"] ?? "ws") == "wss" ? 443 : 80);
|
||||
$this->client = new Client($this->parse["host"], $port, (($this->parse["scheme"] ?? "ws") == "wss" ? true : false));
|
||||
$this->client->set($set);
|
||||
@@ -85,18 +86,18 @@ class ZMWebSocket
|
||||
}
|
||||
}
|
||||
|
||||
if(!debug_backtrace()) {
|
||||
if (!debug_backtrace()) {
|
||||
go(function () {
|
||||
require_once __DIR__ . "/../../Framework/Console.php";
|
||||
$cli = new ZMWebSocket("ws://127.0.0.1:20001/");
|
||||
if (!$cli->is_available) die("Error!\n");
|
||||
$cli->onMessage(function ($frame){
|
||||
$cli->onMessage(function (Frame $frame) {
|
||||
var_dump($frame);
|
||||
});
|
||||
$cli->onClose(function($client){
|
||||
$cli->onClose(function () {
|
||||
echo "Connection closed.\n";
|
||||
});
|
||||
if($cli->upgrade()){
|
||||
if ($cli->upgrade()) {
|
||||
echo "成功连接!\n";
|
||||
} else {
|
||||
echo "连接失败!\n";
|
||||
|
||||
Reference in New Issue
Block a user