/** * @test */ public function it_should_send_message() { $this->socketMessage = $this->socketMessage->reveal(); $this->messageComposer->compose($this->socketMessage)->willReturn('binary'); $this->stream->write('binary')->shouldBeCalledTimes(1); $this->streamHandler->sendMessage($this->socketMessage); }
/** * Sends message to stream sever * * @param SocketMessage $socketMessage * * @return void * @throws DomainException */ public function sendMessage(SocketMessage $socketMessage) { try { $binaryMessage = $this->messageComposer->compose($socketMessage); $this->stream->write($binaryMessage); } catch (\Exception $e) { $this->logger->critical('Error during send a message with ' . $socketMessage->getMessageType()->getType() . ' and id ' . $socketMessage->getCorrelationID() . '. Message Error: ' . $e->getMessage()); } }