@@ -58,3 +58,7 @@ NOTICE
see [official doc](https://www.workerman.net/doc/webman/plugin/console.html)
+### Custormized Processes
+
+see [https://www.workerman.net/doc/webman/process.html](https://www.workerman.net/doc/webman/process.html)
@@ -33,5 +33,15 @@ return [
'php', 'html', 'htm', 'env'
]
- ]
+ ],
+ 'websocket' => [
+ 'handler' => process\TcpServer::class,
+ 'listen' => 'websocket://0.0.0.0:8888',
+ 'count' => 1,
+ // 'log_cleaner' => [
+ // 'handler' => process\WorkerLogCleaner::class,
+ // ]
];
+// see [https://www.workerman.net/doc/webman/process.html](https://www.workerman.net/doc/webman/process.html)
@@ -0,0 +1,28 @@
+<?php
+namespace process;
+use Workerman\Connection\TcpConnection;
+class TcpServer
+{
+ public function onConnect(TcpConnection $conn)
+ {
+ echo 'onConnect\n';
+ }
+ public function onWebSocketConnect(TcpConnection $conn, $http_buffer)
+ echo 'onWebSocketConnect\n';
+ public function onMessage(TcpConnection $conn, $data)
+ $conn->send($data);
+ public function onClose($value='')
+ echo 'onClose\n';
+}
@@ -0,0 +1,16 @@
+use Workerman\Timer;
+use support\Db;
+class WorkerLogCleaner
+ public function onWorkerStart()
+ Timer::add(10, function(){
+ echo 'Removing log...';
+ });