4343#define VERSION_MINOR 0
4444
4545#define ARCUS_SIGNATURE 0x2BAD
46- #define SIG (n ) (((n)& 0xffff0000 ) >> 16 )
46+ #define SIG (n ) (((n) & 0xffff0000 ) >> 16 )
4747
4848#define SOCKET_CLOSE 0xf0f0f0f0
4949
@@ -338,33 +338,35 @@ void Socket::Private::run()
338338// Send a message to the connected socket.
339339void Socket::Private::sendMessage (const MessagePtr& message)
340340{
341- uint32_t header = (ARCUS_SIGNATURE << 16 ) | (VERSION_MAJOR << 8 ) | (VERSION_MINOR);
341+ const uint32_t header = (ARCUS_SIGNATURE << 16 ) | (VERSION_MAJOR << 8 ) | (VERSION_MINOR);
342342 if (platform_socket.writeUInt32 (header) == -1 )
343343 {
344344 error (ErrorCode::SendFailedError, " Could not send message header" );
345345 return ;
346346 }
347347
348- uint32_t message_size = message->ByteSizeLong ();
348+ const uint32_t message_size = message->ByteSizeLong ();
349349 if (platform_socket.writeUInt32 (message_size) == -1 )
350350 {
351351 error (ErrorCode::SendFailedError, " Could not send message size" );
352352 return ;
353353 }
354354
355- uint32_t type_id = message_types.getMessageTypeId (message);
355+ const uint32_t type_id = message_types.getMessageTypeId (message);
356356 if (platform_socket.writeUInt32 (type_id) == -1 )
357357 {
358358 error (ErrorCode::SendFailedError, " Could not send message type" );
359359 return ;
360360 }
361361
362- std::string data = message->SerializeAsString ();
362+ const std::string data = message->SerializeAsString ();
363363 if (platform_socket.writeBytes (data.size (), data.data ()) == -1 )
364364 {
365365 error (ErrorCode::SendFailedError, " Could not send message data" );
366+ return ;
366367 }
367- DEBUG (std::string (" Sending message of type " ) + std::to_string (type_id) + " and size " + std::to_string (message_size));
368+
369+ DEBUG (std::string (" Sent message of type " ) + std::to_string (type_id) + " and size " + std::to_string (message_size));
368370}
369371
370372// Handle receiving data until we have a proper message.
@@ -571,4 +573,4 @@ void Socket::Private::checkConnectionState()
571573}
572574} // namespace Arcus
573575
574- #endif // SOCKET_P_H
576+ #endif // SOCKET_P_H
0 commit comments