This repository was archived by the owner on Jun 3, 2024. It is now read-only.
File tree 1 file changed +10
-2
lines changed
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;
8
8
9
9
class {{ class }}
10
10
{
11
+ protected $worker;
12
+
11
13
public function onWorkerStart(Worker $worker)
12
14
{
15
+ $this->worker = $worker;
16
+
13
17
var_dump("worker {$worker->id} start");
14
18
}
15
19
@@ -20,18 +24,22 @@ class {{ class }}
20
24
21
25
public function onConnect(TcpConnection $connection)
22
26
{
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}");
24
30
}
25
31
26
32
public function onMessage(TcpConnection $connection, $data)
27
33
{
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);
29
35
30
36
$connection->send($message);
31
37
}
32
38
33
39
public function onClose(TcpConnection $connection)
34
40
{
35
41
$connection->close();
42
+
43
+ var_dump("the worker_id {$this->worker->id} of connection_id {$connection->id} closed");
36
44
}
37
45
}
You can’t perform that action at this time.
0 commit comments