Skip to content

Commit

Permalink
pack
Browse files Browse the repository at this point in the history
  • Loading branch information
fucongcong committed Jul 25, 2017
1 parent 2143d62 commit 25f0b0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
//通信协议 eof:结束符, buf:自定义包头+包体
'protocol' => 'buf',
//包体的打包方式json,serialize
'pack' => 'json',
'pack' => 'serialize',
//是否启用gzip压缩true,false
'gzip' => true,

Expand Down
7 changes: 4 additions & 3 deletions src/Admin/Process/HeartbeatProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Group\Process;
use Group\Sync\Dao\Dao;
use Group\Sync\SyncApp;
use Group\Async\Client\Tcp;
use Group\Protocol\Protocol;
use Group\Protocol\Client;

class HeartbeatProcess extends Process
{
Expand All @@ -24,9 +24,10 @@ public function register()
$res = $dao->querySql($sql, 'default')->fetchAll();

foreach ($res as $serv) {
$client = new Tcp($serv['ip'], $serv['port']);
$client = new Client($serv['ip'], $serv['port']);
$client = $client->getClient();
$client->setTimeout(5);
$client->setData(Protocol::pack('', 'p'));
$client->setData(Protocol::pack('ping'));
$client->call(function($response, $error, $calltime) use ($serv, $dao) {
//服务挂了,或者异常了
if (!$response) {
Expand Down

0 comments on commit 25f0b0a

Please sign in to comment.