Workerman? ???? ??? ???? ???? ???? ??
Nov 07, 2023 am 11:00 AM???? ??? ??? ??? ????? ?? ??? ???? ?? ? ??? ??? ???? ???? ?? ? ????? ????. ? ???? Workerman? ???? ??? ???? ???? ???? ??? ?????. ???? ??? ?? ??, ?? ??, ?? ?? ? ??? ??? ??? ????? ? ????. ?? ????? ??? ?? ??? ?? ??? ?????. ??? ??? ?? ??? ??????.
Workerman? ?? PHP? ??? ??? TCP/UDP ?? ?????? ?? ???, ?? ?? ?? ? ?? ??? ?????. Workerman? ???? ? ?? ???, ???, ??? ?? ?? ?? ?? ?? ???, ?? ??? ?????? ????? ?? ??? ? ????. ????? Workerman? ???? ??? ???? ???? ???? ??? ?????.
- Workerman ?????? ???
Workerman? ???? ?? ?????? ?????? ???? ???. ???? Linux ??? ?? ?? Composer? ???? ?????. Workerman? ????? ???? ?? ??? ?????.
composer require Workerman/workerman
??? ??? ? PHP ??? ???? ? ?? Workerman ??????? ??? ? ????.
require_once DIR . '/vendor/autoload.php';
// ?? 2345? ???? websocket ????? ???? ???? ???? ????.
$ws_worker = new WorkermanWorker("websocket:/ /0.0.0.0:2345");
// ?? ??? ??? ?? 4? ???? ??
$ws_worker->count = 4;
// ?????? ????? ???? ?? ???
$ws_worker-> onConnect = function ($connection) {
$connection->send('Welcome to workerman!');
};
// ?????? ???? ??? ?????
$ws_worker->onMessage = function ($connection, $data) {
// 把收到的消息回顯給客戶端 $connection->send($data);
};
/ / ????? ??? ???? ??
$ws_worker->onClose = function ($connection) {
echo "Connection closed
";
};
// ?? Worker
WorkermanWorker::run();
? ?????. ????? ?? 2345? ???? websocket ????? ???? ???? ???? ??????. ?????? ????? ???? ?????? ???? ?? ? ??? ???? ?????? ?????. ????? ??? ??? ??? ????? ???? ?????. ????? Worker? ???? ?????.
- ??? ???? ?? ??
?? Workerman ??????? ????? ?????? ???? ????. ??? ???? ?? ?? ???? Workerman? ???? ??? ???? ??? ???? ??? ?????. ?? ??? ???? ????? ?????? ?? ???? ???? ??? ?? ???.
??? ???? ???. ???? ????? ??? ??? ?????? ?? ?????? ???? ????? ???? ???. Worker? onMessage ???? ???? ???? ?? ????? ????? ? ????. ??? ??? ?? ????? ?? ???? ??? ??? ????:
require_once
DIR . '/vendor/autoload.php';use WorkermanLibTimer;use WorkermanWorker;
$ws_worker = new Worker("websocket ://0.0.0.0:2345");
$ws_worker-> count = 4;
$log_dir = '/path/to/log-dir/';
$monitor_interval = 1; // ?? ?? ?? ?? ????, ??: ?
$ws_worker->onMessage = ??( $connection, $data) use($log_dir) {
// do something
};
$ws_worker->onClose = ??($connection) {
echo "Connection closed
";
};
// ?? ?? ????
if (!is_dir($log_dir)) { return; } $files = scandir($log_dir); foreach ($files as $file) { if ($file == "." || $file == "..") { continue; } $filename = $log_dir . '/' . $file; if (is_file($filename)) { $fp = fopen($filename, 'r'); $lastpos = $ws_worker->lastpos[$filename] ?? 0; fseek($fp, $lastpos); $data = fread($fp, filesize($filename) - $lastpos); fclose($fp); if (!empty($data)) { // 實(shí)時(shí)推送日志信息到前端 foreach($ws_worker->connections as $con){ if ($con->websocket) { $con->send(json_encode(array( 'type' => 'log', 'data' => $data, 'filename' => $filename ))); } } // 更新上次讀取位置 $ws_worker->lastpos[$filename] = ftell($fp); } } }
});
Workerman? Timer ???? ?????. ?? ??? ????? ???? ? ????. ?? ???? ?? ????? ????? ????? ? ????. ?? ??? ?? ? ?? ??? ??? ???? ?? ??? ????? ?? ??? ???? ???. ?? ??? ?? ? ??? ??? ???? ????? ?????.
2.2 ??? ?? ?? ??
??? ???? ????? ??? ?? ?? ?? ???? ?????. ????? ?? ??? ?? ???? ???? ????? ?????? ?? ??? ??? ? ????. ??? ?? ??? ?? ?? ?????.
require_once
DIR . '/vendor/autoload.php';use WorkermanLibTimer;use WorkermanWorker;
$ws_worker = new Worker("websocket://0.0. 0.0:2345 ");
$ws_worker->count = 4;
$alarm_interval = 1; // ?? ??? ???? ?? ??, ??: ?
$ws_worker->onMessage = function ($connection, $data) {
// do something
};
$ws_worker->onClose = function ($connection) {
echo "Connection closed
";
};
// ?? ??? ????
// 監(jiān)控邏輯 $alarm_type = 'warning'; // 告警類型 $alarm_data = 'alarm data'; // 告警數(shù)據(jù) if ($alarm_type && $alarm_data) { // 實(shí)時(shí)推送告警信息到前端 foreach($ws_worker->connections as $con){ if ($con->websocket) { $con->send(json_encode(array( 'type' => 'alarm', 'data' => $alarm_data, 'alarm_type' => $alarm_type ))); } } }
});
?? ???? ????? ??????, ?? ???? ??? ?? ???? ??? ?????. ?? ???? ???? ?? ??? ????? ??? ??? ?????. .
- ??
Workerman? ???? ??? ???? ???? ???? ???? ?? ??? ????? ???? ??? ?? ? ?? ??? ???? ???? ?? ? ????. ? ???? Workerman? ???? ???? ????? ?? ???? ? ??? ?? ??? ???? ??? ????, ?? ?? ??? ?????. ??? ??? ???? ?? ???? ??? ?? ???? ?? ??? ??? ???? ???? ??? ? ????.
? ??? Workerman? ???? ??? ???? ???? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

settings.json ??? ??? ?? ?? ?? ?? ?? ??? ??? VSCODE ??? ??? ???? ? ?????. 1. ??? ?? ?? : Windows? C : \ Users \\ AppData \ Roaming \ Code \ User \ Settings.json, MacOS IS /users//library/applicationsupport/code/user/settings.json, linux? /home//.config/code/user/settings.json; 2. Workspace ?? ?? : .vscode/settings project root ????

DateTime.strpTime ()? ???? ?? ???? DateTime ??? ??????. 1. ?? ?? : "%y-%m-%d"? ?? DateTime ???? "2023-10-05"; 2. ?? ??? "%m/%d/%y", "%d/%m/%y", ?? ??? ?? ???? ?? "%b%d,%y%i :%m%p"? ?? ?? ??? ?????. 3. dateUtil.parser.parse ()? ???? ? ??? ??? ???? ?????. 4. ?? .D

?, ?? CSS ?? ?? ??? JavaScript??? ??? HTML ? CSS? ?? ??? ? ????. 1. ?? UL? Li? ???? ?? ??? ??????. 2. ?? ?? ???? ???? ?????? ???? ??? ???? ???; 3. ?? ?? : ?? Li? ???, ?? ??? ??? ???? ?????. ??; 4. ?? ??? ???? ??? : ??, ????????? : ???? ??; 5. ?? ?? ???? ??? ?? ????, ??? ????, ??? ? ?????? ???? ??? ????? ??? ???? ??? ? ????. ?? ???? ???? JavaScript ??? ???? ???? ??? ?????.

@Property Decorator? ??? ??, ?? ? ?? ??? ???? ?? ???? ???? ???? ? ?????. 1. ?? ?? : @property? ?? ?? ?? ??? ????, ?? ?? ??? ???? ???? ?? ????? ??; 2. ?? ?? : @name.setter ? @name.deleter? ???? ?? ?? ?? ? ?? ??? ?????. 3. ?? ?? ???? : BankAccount? ?? ???? ??? ??? ???? ??? ??? ??? ??????. 4. ?? ?? ?? : ?? ??? ????? ?? ??? ??? ??? ???? ?? ??? ??? ?? ?? ? ?? ??? ?????.

itertools.combinations? ?? ??? ???? ??? ?? ??? ???? ?? ? ?? ?? (?? ???)? ???? ? ?????. ???? ??? ????. 1. ?? ??? ??? ?? ( 'a', 'b'), ( 'a', 'c') ? ???? 2 ?? ?? ??? ?????. 2. ?? ??? ??? "ABC"? "ABD"? ?? ???? 3 ? ??? ???; 3. ? ??? ?? 1 5 = 6? ?? ?? ?? ??? ??? ?????. ?? ?? ??? ???????. ??? ??? ??? ??? ???? ??????, ??? AB? BA? ???? ???? ??, ??? ?? ??? ????.

Python? ETL ????? ???? ???? ?????. 1. ??? ?? : ??????, API, ?? ? ?? ???? Pandas, Sqlalchemy, ?? ? ?? ?????? ?? ???? ?? ? ? ????. 2. ??? ?? : ??, ?? ??, ???, ?? ? ?? ??? ??? ???? ??? ??? ???? ??? ??????. 3. ??? ?? : Pandas 'To_SQL ??? ?? ???? ??? SDK? ???? ?? ???? ???? ???? ?? ?? ? ?? ?????? ?????. 4. ?? ?? ?? : ?? ??, Dagster, Prefect? ???? ???? ? ??? ???? ?? ?? ? ?? ??? ???? ???? ?? ??? ??????.

???? ?? ?? ?? ?? ???? ?? ???? ???? ? ???? ?????. 1. @pytest.fixture ?????? ???? ???? ??????. 2. ??? ???? ???? ??? ???? ??; 3. ?? ?? ??? ?? ? ?? ??; 4. ??, ?? ?? ?? ?? ?? ??? ?? ?? ??; 5. ?? ???? Conftest.py? ???? ??? ?? ??? ???? ???? ?? ?? ? ??? ?? ??????.

UUID ??? ???? ?? ?????? ???? ??? ??? ??? ? ?? ???? ??? MAC ??? ?? UUID.getNode ()? ?? ?? ???? ??????. 2. ?? ????? ???? IPConfig ?? ifconfig? ?? ??? ??? ???? ?? ???? ?? MAC ??? ??? ? ??? ???? ?? ???? ?? ??? ????? ????? ?????. 3. ?? ????? GetMac? ???? ?? ? get_mac_address ()? ???? Mac? ???? ????? ?? IP? ??? ????? ?? ???? ?????. ???? ?? ?????? ???? ??? UUID ??? ?????. ?? ???? ?? ??? ???? ????? ?? ?? ???? ???? ???? ??? getma? ??? ? ????.
