Print RPC MethodName and ResponseMsgName on server
This commit is contained in:
parent
1f6af2e4cc
commit
10dddf410a
@ -114,7 +114,9 @@ void RpcConnection::writeHeader(char* header, quint16 type, quint16 method,
|
|||||||
*((quint32*)(header+4)) = qToBigEndian(length);
|
*((quint32*)(header+4)) = qToBigEndian(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RpcConnection::sendRpcReply(PbRpcController *controller)
|
void RpcConnection::sendRpcReply(
|
||||||
|
const ::google::protobuf::MethodDescriptor *method,
|
||||||
|
PbRpcController *controller)
|
||||||
{
|
{
|
||||||
google::protobuf::Message *response = controller->response();
|
google::protobuf::Message *response = controller->response();
|
||||||
QIODevice *blob;
|
QIODevice *blob;
|
||||||
@ -178,8 +180,10 @@ void RpcConnection::sendRpcReply(PbRpcController *controller)
|
|||||||
qDebug("Server(%s): sending %d bytes to client <----",
|
qDebug("Server(%s): sending %d bytes to client <----",
|
||||||
__FUNCTION__, len + PB_HDR_SIZE);
|
__FUNCTION__, len + PB_HDR_SIZE);
|
||||||
BUFDUMP(msg, 8);
|
BUFDUMP(msg, 8);
|
||||||
qDebug("method = %d\nreq = \n%s---->",
|
qDebug("method = %d:%s\nresp = %s\n%s---->",
|
||||||
pendingMethodId, response->DebugString().c_str());
|
pendingMethodId, method ? method->name().c_str() : "",
|
||||||
|
method ? method->output_type()->name().c_str() : "",
|
||||||
|
response->DebugString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
clientSock->write(msg, PB_HDR_SIZE);
|
clientSock->write(msg, PB_HDR_SIZE);
|
||||||
@ -343,16 +347,19 @@ void RpcConnection::on_clientSock_dataAvail()
|
|||||||
bool ok = req->ParseFromBoundedZeroCopyStream(inStream, len);
|
bool ok = req->ParseFromBoundedZeroCopyStream(inStream, len);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
qWarning("ParseFromBoundedZeroCopyStream fail "
|
qWarning("ParseFromBoundedZeroCopyStream fail "
|
||||||
"for method %d and len %d", method, len);
|
"for method %d:%s and len %d",
|
||||||
|
method, methodDesc->name().c_str(),len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req->IsInitialized())
|
if (!req->IsInitialized())
|
||||||
{
|
{
|
||||||
qWarning("Missing required fields in request <----");
|
qWarning("Missing required fields in request <----");
|
||||||
qDebug("method = %d\n"
|
qDebug("method = %d:%s\n"
|
||||||
"req = \n%s"
|
"req = %s\n%s"
|
||||||
"missing = \n%s----->",
|
"missing = \n%s----->",
|
||||||
method, req->DebugString().c_str(),
|
method, methodDesc->name().c_str(),
|
||||||
|
methodDesc->input_type()->name().c_str(),
|
||||||
|
req->DebugString().c_str(),
|
||||||
req->InitializationErrorString().c_str());
|
req->InitializationErrorString().c_str());
|
||||||
error = QString("RPC %1() missing required fields in request - %2")
|
error = QString("RPC %1() missing required fields in request - %2")
|
||||||
.arg(QString::fromStdString(
|
.arg(QString::fromStdString(
|
||||||
@ -367,9 +374,10 @@ void RpcConnection::on_clientSock_dataAvail()
|
|||||||
|
|
||||||
if (method != 13) {
|
if (method != 13) {
|
||||||
qDebug("Server(%s): successfully received/parsed msg <----", __FUNCTION__);
|
qDebug("Server(%s): successfully received/parsed msg <----", __FUNCTION__);
|
||||||
qDebug("method = %d\n"
|
qDebug("method = %d:%s\n"
|
||||||
"req = \n%s---->",
|
"req = %s\n%s---->",
|
||||||
method,
|
method, methodDesc->name().c_str(),
|
||||||
|
methodDesc->input_type()->name().c_str(),
|
||||||
req->DebugString().c_str());
|
req->DebugString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +387,7 @@ void RpcConnection::on_clientSock_dataAvail()
|
|||||||
|
|
||||||
service->CallMethod(methodDesc, controller, req, resp,
|
service->CallMethod(methodDesc, controller, req, resp,
|
||||||
google::protobuf::NewCallback(this, &RpcConnection::sendRpcReply,
|
google::protobuf::NewCallback(this, &RpcConnection::sendRpcReply,
|
||||||
controller));
|
methodDesc, controller));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -394,7 +402,7 @@ _error_exit2:
|
|||||||
controller->SetFailed(error);
|
controller->SetFailed(error);
|
||||||
if (disconnect)
|
if (disconnect)
|
||||||
controller->TriggerDisconnect();
|
controller->TriggerDisconnect();
|
||||||
sendRpcReply(controller);
|
sendRpcReply(methodDesc, controller);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ namespace google {
|
|||||||
class CopyingOutputStreamAdaptor;
|
class CopyingOutputStreamAdaptor;
|
||||||
}
|
}
|
||||||
class Message;
|
class Message;
|
||||||
|
class MethodDescriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void writeHeader(char* header, quint16 type, quint16 method,
|
void writeHeader(char* header, quint16 type, quint16 method,
|
||||||
quint32 length);
|
quint32 length);
|
||||||
void sendRpcReply(PbRpcController *controller);
|
void sendRpcReply(const ::google::protobuf::MethodDescriptor *method,
|
||||||
|
PbRpcController *controller);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void closed();
|
void closed();
|
||||||
|
Loading…
Reference in New Issue
Block a user