Skip to content

Commit c0f30c6

Browse files
committed
mod: RpcDecoder holds a ITransport ptr
1 parent ff8d4df commit c0f30c6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/decoder.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ template<size_t BufferSize = MAX_BUFFER_SIZE>
2727
class RpcDecoder {
2828

2929
public:
30-
explicit RpcDecoder(ITransport& transport) : _transport(transport) {}
30+
explicit RpcDecoder(ITransport& transport) : _transport(&transport) {}
3131

3232
template<typename... Args>
3333
bool send_call(const int call_type, const MsgPack::str_t& method, uint32_t& msg_id, Args&&... args) {
@@ -160,8 +160,8 @@ class RpcDecoder {
160160
// Fill the raw buffer to its capacity
161161
void advance() {
162162

163-
if (_transport.available() && !buffer_full()) {
164-
size_t bytes_read = _transport.read(_raw_buffer + _bytes_stored, BufferSize - _bytes_stored);
163+
if (_transport->available() && !buffer_full()) {
164+
size_t bytes_read = _transport->read(_raw_buffer + _bytes_stored, BufferSize - _bytes_stored);
165165
_bytes_stored += bytes_read;
166166
}
167167

@@ -215,7 +215,7 @@ class RpcDecoder {
215215
friend class DecoderTester;
216216

217217
private:
218-
ITransport& _transport;
218+
ITransport* _transport;
219219
uint8_t _raw_buffer[BufferSize] = {};
220220
size_t _bytes_stored = 0;
221221
int _packet_type = NO_MSG;
@@ -226,13 +226,13 @@ class RpcDecoder {
226226

227227
bool buffer_empty() const { return _bytes_stored == 0;}
228228

229-
// This is a blocking send, under the assumption _transport.write will always succeed eventually
229+
// This is a blocking send, under the assumption _transport->write will always succeed eventually
230230
size_t send(const uint8_t* data, const size_t size) const {
231231

232232
size_t offset = 0;
233233

234234
while (offset < size) {
235-
size_t bytes_written = _transport.write(data + offset, size - offset);
235+
size_t bytes_written = _transport->write(data + offset, size - offset);
236236
offset += bytes_written;
237237
}
238238

0 commit comments

Comments
 (0)