Fixed message parsing bug
This commit is contained in:
@ -74,7 +74,8 @@ class CommandBusClient implements CommandBusInterface
|
||||
$this->connection = $connection;
|
||||
$this->emit(self::EVENT_CONNECTED);
|
||||
$connection->on('error', function ($error) {
|
||||
$this->emit(self::EVENT_DISCONNECTED, [ $error ]);
|
||||
$this->emit(self::EVENT_ERROR, [ $error ]);
|
||||
$this->emit(self::EVENT_DISCONNECTED);
|
||||
if ($this->autoReconnect) {
|
||||
Loop::addTimer(1, $this->reconnect(...));
|
||||
}
|
||||
@ -89,8 +90,10 @@ class CommandBusClient implements CommandBusInterface
|
||||
});
|
||||
$connection->on('data', function ($data) use ($connection) {
|
||||
try {
|
||||
$message = Message::fromString($data);
|
||||
$this->onServerMessage($message);
|
||||
$messages = Message::fromStringMulti($data);
|
||||
foreach ($messages as $message) {
|
||||
$this->onServerMessage($message);
|
||||
}
|
||||
} catch (MessageException $e) {
|
||||
$connection->end('{"msg":"error","data":{"error":"Bad message format"}}');
|
||||
}
|
||||
|
Reference in New Issue
Block a user