update to 1.5.2 version

add ZM_VERSION const
This commit is contained in:
whale
2020-06-08 23:52:55 +08:00
parent 9ba58ff90f
commit c0ea068d04
4 changed files with 11 additions and 7 deletions

View File

@@ -1,9 +1,9 @@
{ {
"name": "zhamao/framework", "name": "zhamao/framework",
"description": "high-performance intelligent assistant", "description": "High performance QQ robot and web server development framework",
"minimum-stability": "stable", "minimum-stability": "stable",
"license": "Apache-2.0", "license": "Apache-2.0",
"version": "1.5.1", "version": "1.5.2",
"authors": [ "authors": [
{ {
"name": "whale", "name": "whale",

View File

@@ -100,7 +100,7 @@ class FrameworkLoader
"host: " . self::$settings->get("host") . "host: " . self::$settings->get("host") .
", port: " . self::$settings->get("port") . ", port: " . self::$settings->get("port") .
", log_level: " . ZMBuf::$atomics["info_level"]->get() . ", 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() "\nworking_dir: " . DataProvider::getWorkingDir()
); );
global $motd; global $motd;
@@ -130,6 +130,7 @@ class FrameworkLoader
private function defineProperties() { private function defineProperties() {
define("ZM_START_TIME", microtime(true)); define("ZM_START_TIME", microtime(true));
define("ZM_DATA", self::$settings->get("zm_data")); 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("CONFIG_DIR", self::$settings->get("config_dir"));
define("CRASH_DIR", self::$settings->get("crash_dir")); define("CRASH_DIR", self::$settings->get("crash_dir"));
@mkdir(ZM_DATA); @mkdir(ZM_DATA);

View File

@@ -222,3 +222,5 @@ function zm_timer_tick($ms, callable $callable) {
} }

View File

@@ -29,6 +29,7 @@ class ZMWebSocket
Console::warning("ZMRequest: url must contains scheme such as \"ws(s)://\""); Console::warning("ZMRequest: url must contains scheme such as \"ws(s)://\"");
return; return;
} }
if (!isset($this->parse["path"])) $this->parse["path"] = "/";
$port = $this->parse["port"] ?? (($this->parse["scheme"] ?? "ws") == "wss" ? 443 : 80); $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 = new Client($this->parse["host"], $port, (($this->parse["scheme"] ?? "ws") == "wss" ? true : false));
$this->client->set($set); $this->client->set($set);
@@ -85,18 +86,18 @@ class ZMWebSocket
} }
} }
if(!debug_backtrace()) { if (!debug_backtrace()) {
go(function () { go(function () {
require_once __DIR__ . "/../../Framework/Console.php"; require_once __DIR__ . "/../../Framework/Console.php";
$cli = new ZMWebSocket("ws://127.0.0.1:20001/"); $cli = new ZMWebSocket("ws://127.0.0.1:20001/");
if (!$cli->is_available) die("Error!\n"); if (!$cli->is_available) die("Error!\n");
$cli->onMessage(function ($frame){ $cli->onMessage(function (Frame $frame) {
var_dump($frame); var_dump($frame);
}); });
$cli->onClose(function($client){ $cli->onClose(function () {
echo "Connection closed.\n"; echo "Connection closed.\n";
}); });
if($cli->upgrade()){ if ($cli->upgrade()) {
echo "成功连接!\n"; echo "成功连接!\n";
} else { } else {
echo "连接失败!\n"; echo "连接失败!\n";