From 7384b521ac42376d3bcf5007c89cfee4aee94c1a Mon Sep 17 00:00:00 2001 From: Jan Westerdiep Date: Fri, 10 Jun 2016 15:21:10 +0200 Subject: [PATCH] small legibility fixes --- README.md | 4 ++-- include/buffer.h | 2 +- include/deferredconsumer.h | 2 +- src/messageimpl.h | 3 +++ src/receivedframe.cpp | 7 ++++--- src/tcpconnected.h | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2804e13..7dd0c1f 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ PARSING INCOMING DATA The ConnectionHandler class has a method onData() that is called by the library every time that it wants to send out data. We've explained that it is up to you to -implement that method. Inside your ConnectionHandler::data() method, you can for +implement that method. Inside your ConnectionHandler::onData() method, you can for example call the "send()" or "write()" system call to send out the data to the RabbitMQ server. But what about data in the other direction? How does the library receive data back from RabbitMQ? @@ -312,7 +312,7 @@ class MyTcpHandler : public AMQP::TcpHandler * and only make "write()" or "read()" system calls when it knows in advance * that these calls will not block. To register a filedescriptor in the * event loop, it calls this "monitor()" method with a filedescriptor and - * flags telling whether the filedescriptor should be checked for reaability + * flags telling whether the filedescriptor should be checked for readability * or writability. * * @param connection The connection that wants to interact with the event loop diff --git a/include/buffer.h b/include/buffer.h index 71bee74..46ee5aa 100644 --- a/include/buffer.h +++ b/include/buffer.h @@ -2,7 +2,7 @@ * Buffer.h * * Interface that can be implemented by client applications and that - * is parsed to the Connection::parse() method. + * is passed to the Connection::parse() method. * * Normally, the Connection::parse() method is fed with a byte * array. However, if you're receiving big frames, it may be inconvenient diff --git a/include/deferredconsumer.h b/include/deferredconsumer.h index df8fd01..597c2ab 100644 --- a/include/deferredconsumer.h +++ b/include/deferredconsumer.h @@ -113,7 +113,7 @@ public: /** * Register a function to be called when a message arrives - * This fuction is also available as onMessage() because I always forget which name I gave to it + * This fuction is also available as onReceived() because I always forget which name I gave to it * @param callback the callback to execute */ DeferredConsumer &onMessage(const MessageCallback &callback) diff --git a/src/messageimpl.h b/src/messageimpl.h index 53bbced..1a8fb03 100644 --- a/src/messageimpl.h +++ b/src/messageimpl.h @@ -86,6 +86,9 @@ public: // we can not safely append the data to the string, it // will not exceed the reserved size so it is guaranteed // not to change the data pointer, we can just leave that + // @todo this is not always necessary; instead, we can refrain from + // allocating this buffer entirely and just insert it into the message + // directly. _str.append(buffer, static_cast(size)); // if the string is filled with the given number of characters we are done now diff --git a/src/receivedframe.cpp b/src/receivedframe.cpp index 96f6d68..eb7af5d 100644 --- a/src/receivedframe.cpp +++ b/src/receivedframe.cpp @@ -72,6 +72,7 @@ #include "framecheck.h" #define TYPE_INVALID 0 +#define END_OF_FRAME -50 /** * Set up namespace @@ -99,12 +100,12 @@ ReceivedFrame::ReceivedFrame(const Buffer &buffer, uint32_t max) : _buffer(buffe if (buffer.size() >= _payloadSize + 8) { // buffer is big enough, check for a valid end-of-frame marker - if ((int)buffer.byte(_payloadSize+7) != -50) throw ProtocolException("invalid end of frame marker"); + if ((int)buffer.byte(_payloadSize+7) != END_OF_FRAME) throw ProtocolException("invalid end of frame marker"); } else { // frame is not yet valid - _type = 0; + _type = TYPE_INVALID; _channel = 0; _payloadSize = 0; } @@ -264,7 +265,7 @@ float ReceivedFrame::nextFloat() /** * Read a double from the buffer * - * @return double boule read from buffer + * @return double double read from buffer */ double ReceivedFrame::nextDouble() { diff --git a/src/tcpconnected.h b/src/tcpconnected.h index 0d98b2a..873505f 100644 --- a/src/tcpconnected.h +++ b/src/tcpconnected.h @@ -141,7 +141,7 @@ public: if (flags & readable) { // read data from buffer - auto result = _in.receivefrom(_socket); + ssize_t result = _in.receivefrom(_socket); // are we in an error state? if (result < 0 && reportError()) return nextState(monitor);