Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit cc7751d

Browse files
authored
Merge pull request #31 from mouyong/master
Update CustomProcess.stub
2 parents 6f06533 + 09eba92 commit cc7751d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Commands/stubs/CustomProcess.stub

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ use Workerman\Connection\TcpConnection;
88

99
class {{ 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
}

0 commit comments

Comments
 (0)