Skip to content

Commit

Permalink
Rewrite RpcDriver::writeFrame() from move to const reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Nov 18, 2024
1 parent 2aa758a commit 26f4281
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libshvchainpack/include/shv/chainpack/rpcdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SHVCHAINPACK_DECL_EXPORT RpcDriver
protected:
virtual bool isOpen() = 0;

virtual void writeFrame(RpcFrame &&frame) = 0;
virtual void writeFrame(const RpcFrame &frame) = 0;

void processRpcFrame(RpcFrame &&frame);
virtual void onRpcFrameReceived(RpcFrame &&frame);
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/include/shv/chainpack/socketrpcdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SHVCHAINPACK_DECL_EXPORT SocketRpcDriver : public RpcDriver
void sendNotify(std::string &&method, const RpcValue &result);
protected:
bool isOpen() override;
void writeFrame(RpcFrame &&frame) override;
void writeFrame(const RpcFrame &frame) override;

virtual void onFrameDataRead(const std::string &frame_data);
virtual void idleTaskOnSelectTimeout();
Expand Down
4 changes: 2 additions & 2 deletions libshvchainpack/src/rpcdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ void RpcDriver::sendRpcFrame(RpcFrame &&frame)
throw std::runtime_error("Cannot convert RPC frame to message: " + errmsg);
}
auto frame2 = msg.toRpcFrame(m_clientProtocolType);
writeFrame(std::move(frame2));
writeFrame(frame2);
}
else {
//logRpcData().nospace() << "FRAME DATA WRITE " << frame_data.size() << " bytes of data:\n" << shv::chainpack::utils::hexDump(frame_data);
writeFrame(std::move(frame));
writeFrame(frame);
}
}
catch (const std::exception &e) {
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/src/socketrpcdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void SocketRpcDriver::idleTaskOnSelectTimeout()
{
}

void SocketRpcDriver::writeFrame(RpcFrame &&frame)
void SocketRpcDriver::writeFrame(const RpcFrame &frame)
{
if(!isOpen()) {
nInfo() << "Write to closed socket";
Expand Down
2 changes: 1 addition & 1 deletion libshviotqt/include/shv/iotqt/rpc/socketrpcconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SHVIOTQT_DECL_EXPORT SocketRpcConnection : public QObject, public shv::cha
protected:
// RpcDriver interface
bool isOpen() Q_DECL_OVERRIDE;
void writeFrame(shv::chainpack::RpcFrame &&frame) override;
void writeFrame(const shv::chainpack::RpcFrame &frame) override;

Socket* socket();
void onReadyRead();
Expand Down
2 changes: 1 addition & 1 deletion libshviotqt/src/rpc/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void StreamFrameWriter::addFrameData(const std::string &frame_head, const std::s
std::ostringstream out;
{
ChainPackWriter wr(out);
wr.writeUIntData(frame_data.size());
wr.writeUIntData(frame_head.size() + frame_data.size());
}
auto len_data = out.str();
QByteArray data(len_data.data(), len_data.size());
Expand Down
2 changes: 1 addition & 1 deletion libshviotqt/src/rpc/socketrpcconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool SocketRpcConnection::isOpen()
return isSocketConnected();
}

void SocketRpcConnection::writeFrame(chainpack::RpcFrame &&frame)
void SocketRpcConnection::writeFrame(const chainpack::RpcFrame &frame)
{
socket()->writeFrame(frame);
}
Expand Down

0 comments on commit 26f4281

Please sign in to comment.