File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 1515#include "Arduino.h"
1616
1717#define DECODER_BUFFER_SIZE 1024
18+ #define RPCLITE_MAX_TRANSPORTS 3
19+
1820//#define HANDLE_RPC_ERRORS
1921#include "transport.h"
2022#include "client.h"
Original file line number Diff line number Diff line change 1414#ifndef RPCLITE_DECODER_MANAGER_H
1515#define RPCLITE_DECODER_MANAGER_H
1616
17- #define RPCLITE_MAX_TRANSPORTS 3
18-
1917#include < array>
2018#include " transport.h"
2119#include " decoder.h"
2220
2321template <size_t MaxTransports = RPCLITE_MAX_TRANSPORTS>
2422class RpcDecoderManager {
2523public:
26- // todo parametrize so the RpcDecoder returned has a user defined buffer size ?
2724 static RpcDecoder<>& getDecoder (ITransport& transport) {
2825 for (auto & entry : decoders_) {
2926 if (entry.transport == &transport) {
Original file line number Diff line number Diff line change @@ -52,15 +52,16 @@ class RPCServer {
5252 bool get_rpc (RPCRequest<RpcSize>& req, MsgPack::str_t tag=" " ) {
5353 decoder->decode ();
5454
55- MsgPack::str_t method = decoder->fetch_rpc_method ();
55+ const MsgPack::str_t method = decoder->fetch_rpc_method ();
5656
5757 if (method == " " || !dispatcher.hasTag (method, tag)) return false ;
5858
5959 req.size = decoder->get_request (req.buffer , RpcSize);
6060 return req.size > 0 ;
6161 }
6262
63- void process_request (RPCRequest<>& req) {
63+ template <size_t RpcSize = DEFAULT_RPC_BUFFER_SIZE>
64+ void process_request (RPCRequest<RpcSize>& req) {
6465
6566 if (!req.unpack_request_headers ()) {
6667 req.reset ();
@@ -73,7 +74,8 @@ class RPCServer {
7374
7475 }
7576
76- bool send_response (const RPCRequest<>& req) const {
77+ template <size_t RpcSize = DEFAULT_RPC_BUFFER_SIZE>
78+ bool send_response (const RPCRequest<RpcSize>& req) const {
7779
7880 if (req.type == NO_MSG || req.packer .size () == 0 ) {
7981 return true ; // No response to send
You can’t perform that action at this time.
0 commit comments