This repository was archived by the owner on Jun 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ use Workerman\Connection\TcpConnection;
88
99class {{ class }}
1010{
11+ protected $worker;
12+
1113 public function onWorkerStart(Worker $worker)
1214 {
15+ $this->worker = $worker;
16+
1317 var_dump("worker {$worker->id} start");
1418 }
1519
@@ -20,18 +24,22 @@ class {{ class }}
2024
2125 public function onConnect(TcpConnection $connection)
2226 {
23- var_dump('client connect to connection_id ' . $connection->id);
27+ $this->connection = $connection;
28+
29+ var_dump("client connect to worker_id {$this->worker->id} successful, current connection_id is {$connection->id}");
2430 }
2531
2632 public function onMessage(TcpConnection $connection, $data)
2733 {
28- var_dump($message = "connection id {$connection->id} receive message from client: " . $data);
34+ var_dump($message = "the worker_id {$this->worker->id} of connection_id {$connection->id} receive message from client: " . $data);
2935
3036 $connection->send($message);
3137 }
3238
3339 public function onClose(TcpConnection $connection)
3440 {
3541 $connection->close();
42+
43+ var_dump("the worker_id {$this->worker->id} of connection_id {$connection->id} closed");
3644 }
3745}
You can’t perform that action at this time.
0 commit comments