diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-03-01 02:03:07 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-03-01 02:03:07 +0300 |
commit | 7b44cbe272e6adf24109a9232a48008a8818f318 (patch) | |
tree | 7725bca8517082fe79fe31af1edfca95dfc76987 /src/Message.php | |
parent | c66fc2f691424023b107dfee1295fa165b223f86 (diff) |
support new protocol
Diffstat (limited to 'src/Message.php')
-rw-r--r-- | src/Message.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Message.php b/src/Message.php index 647afad..92c6005 100644 --- a/src/Message.php +++ b/src/Message.php @@ -7,6 +7,8 @@ abstract class Message { const REQUEST = 0; const RESPONSE = 1; + const PING = 2; + const PONG = 3; protected $type; @@ -27,10 +29,13 @@ abstract class Message { * @return string */ public function serialize(): string { - return json_encode([ - $this->type, - $this->getContent() - ]); + $data = [$this->type]; + $content = $this->getContent(); + + if (!empty($content)) + $data[] = $content; + + return json_encode($data); } }
\ No newline at end of file |