Refactoring: Cleanup RPC Channel's knowledge of notification prototype

Updates issue 144
This commit is contained in:
Srivats P. 2015-04-25 20:12:37 +05:30
parent ad6baea4af
commit 9be69a8f46
3 changed files with 10 additions and 7 deletions

View File

@ -57,7 +57,8 @@ PortGroup::PortGroup(QHostAddress ip, quint16 port)
connect(reconnectTimer, SIGNAL(timeout()),
this, SLOT(on_reconnectTimer_timeout()));
rpcChannel = new PbRpcChannel(ip, port);
rpcChannel = new PbRpcChannel(ip, port,
OstProto::Notification::default_instance());
serviceStub = new OstProto::OstService::Stub(rpcChannel);
// FIXME(LOW):Can't for my life figure out why this ain't working!

View File

@ -20,13 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "pbrpcchannel.h"
#include "pbqtio.h"
#include "../common/protocol.pb.h" // FIXME: temp
#include <qendian.h>
static uchar msgBuf[4096];
PbRpcChannel::PbRpcChannel(QHostAddress ip, quint16 port)
PbRpcChannel::PbRpcChannel(QHostAddress ip, quint16 port,
const ::google::protobuf::Message &notifProto)
: notifPrototype(notifProto)
{
isPending = false;
pendingMethodId = -1; // don't care as long as isPending is false
@ -334,8 +334,8 @@ void PbRpcChannel::on_mpSocket_readyRead()
{
//qDebug("client(%s) rcvd %d bytes", __FUNCTION__, msgLen);
//BUFDUMP(msg, msgLen);
#if 0
notif = serviceStub->GetNotificationPrototype(method).New();
#if 1
notif = notifPrototype.New();
#else
notif = new OstProto::Notification;
#endif

View File

@ -61,6 +61,7 @@ class PbRpcChannel : public QObject, public ::google::protobuf::RpcChannel
} RpcCall;
QList<RpcCall> pendingCallList;
const ::google::protobuf::Message &notifPrototype;
::google::protobuf::Message *notif;
QHostAddress mServerAddress;
@ -71,7 +72,8 @@ class PbRpcChannel : public QObject, public ::google::protobuf::RpcChannel
::google::protobuf::io::CopyingOutputStreamAdaptor *outStream;
public:
PbRpcChannel(QHostAddress ip, quint16 port);
PbRpcChannel(QHostAddress ip, quint16 port,
const ::google::protobuf::Message &notifProto);
~PbRpcChannel();
void establish();