@@ -27,10 +27,10 @@ template<size_t BufferSize = MAX_BUFFER_SIZE>
2727class RpcDecoder {
2828
2929public:
30- RpcDecoder (ITransport& transport) : _transport(transport) {}
30+ explicit RpcDecoder (ITransport& transport) : _transport(transport) {}
3131
3232 template <typename ... Args>
33- bool send_call (const int call_type, const MsgPack::str_t method, uint32_t & msg_id, Args&&... args) {
33+ bool send_call (const int call_type, const MsgPack::str_t & method, uint32_t & msg_id, Args&&... args) {
3434
3535 if (call_type!=CALL_MSG && call_type!=NOTIFY_MSG) return false ;
3636
@@ -89,7 +89,7 @@ class RpcDecoder {
8989
9090 }
9191
92- bool send_response (const MsgPack::Packer& packer) {
92+ bool send_response (const MsgPack::Packer& packer) const {
9393 return send (reinterpret_cast <const uint8_t *>(packer.data ()), packer.size ()) == packer.size ();
9494 }
9595
@@ -111,7 +111,6 @@ class RpcDecoder {
111111 };
112112
113113 int msg_type;
114- uint32_t msg_id;
115114 MsgPack::str_t method;
116115 MsgPack::arr_size_t req_size;
117116
@@ -122,6 +121,7 @@ class RpcDecoder {
122121 }
123122
124123 if (msg_type == CALL_MSG && req_size.size () == REQUEST_SIZE) {
124+ uint32_t msg_id;
125125 if (!unpacker.deserialize (msg_id, method)) {
126126 consume (_packet_size);
127127 reset_packet ();
@@ -204,30 +204,30 @@ class RpcDecoder {
204204
205205 }
206206
207- inline bool packet_incoming () const { return _packet_size >= MIN_RPC_BYTES; }
207+ bool packet_incoming () const { return _packet_size >= MIN_RPC_BYTES; }
208208
209- inline int packet_type () const { return _packet_type; }
209+ int packet_type () const { return _packet_type; }
210210
211211 size_t get_packet_size () const { return _packet_size;}
212212
213- inline size_t size () const {return _bytes_stored;}
213+ size_t size () const {return _bytes_stored;}
214214
215215 friend class DecoderTester ;
216216
217217private:
218218 ITransport& _transport;
219- uint8_t _raw_buffer[BufferSize];
219+ uint8_t _raw_buffer[BufferSize] = {} ;
220220 size_t _bytes_stored = 0 ;
221221 int _packet_type = NO_MSG;
222222 size_t _packet_size = 0 ;
223223 uint32_t _msg_id = 0 ;
224224
225- inline bool buffer_full () const { return _bytes_stored == BufferSize; }
225+ bool buffer_full () const { return _bytes_stored == BufferSize; }
226226
227- inline bool buffer_empty () const { return _bytes_stored == 0 ;}
227+ bool buffer_empty () const { return _bytes_stored == 0 ;}
228228
229229 // This is a blocking send, under the assumption _transport.write will always succeed eventually
230- inline size_t send (const uint8_t * data, const size_t size) {
230+ size_t send (const uint8_t * data, const size_t size) const {
231231
232232 size_t offset = 0 ;
233233
0 commit comments