From 7b44cbe272e6adf24109a9232a48008a8818f318 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Mon, 1 Mar 2021 02:03:07 +0300 Subject: support new protocol --- src/Message.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Message.php') 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 -- cgit v1.2.3