ostinato/rpc/pbrpcchannel.h
Srivats P. 84c7fe1e06 Features
- Added support for retrieving the packet capture buffer from server to client (does not work consistently however - needs investigation)
		- getCaptureBuffer() Rpc signature changed
	- RPC: Added support in Rpc Channel (client) to queue calls
	- RPC: Added support for transferring arbitrary binary data from server to client (used to get packet capture files)
		- Rpc header changed - length is now 4 bytes instead of 2; there is no rsvd field any longer

Fixes
	- RPC: Fix for the case when a msg is not received all at once over the socket
	- StreamConfigDialog: fixed display issue in packet view for combo protocols containing meta fields
	- Fixed issue with Stacked Vlan not retaining data for both CVlan and SVlan
	- Fixed incorrect payload size issue with increment/decrement frame length modes

Refactoring, Cleanup etc.
	- RPC: Minor code and TODOs cleanup
	- Server: Minor code and TODOs cleanup
	- Server: Removed unused file(s): rxtx.cpp, rxtx.h
	- Server: Replaced direct use of ProtocolList with the ProtocolListIterator
	- Common: Minor code and TODOs cleanup
	- StreamBase::frameLen() now returns the length based on the mode/min/max and the passed in streamIndex
	- AbstractProtocol interface changed for methods - protocolFrameSize(), protocolFrameOffset(), protocolFramePayloadSize() : all of them now take streamIndex as an optional param with 0 as the default value
		- Protocols implementing the above methods changed accordingly
2009-11-03 14:02:09 +00:00

84 lines
2.5 KiB
C++

#ifndef _PB_RPC_CHANNEL_H
#define _PB_RPC_CHANNEL_H
#include <QTcpServer>
#include <QTcpSocket>
#include <google/protobuf/message.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/service.h>
#include "pbrpccommon.h"
#include "pbrpccontroller.h"
class PbRpcChannel : public QObject, public ::google::protobuf::RpcChannel
{
Q_OBJECT
// If isPending is TRUE, then controller, done, response
// and pendingMethodId correspond to the last method called by
// the service stub
bool isPending;
int pendingMethodId;
// controller, done, response are set to the corresponding values
// passed by the stub to CallMethod(). They are reset to NULL when
// we get a response back from the server in on_mpSocket_readyRead()
// after calling done->Run().
/*! \todo (MED) : change controller, done and response to references
instead of pointers? */
::google::protobuf::RpcController *controller;
::google::protobuf::Closure *done;
::google::protobuf::Message *response;
typedef struct _RpcCall {
const ::google::protobuf::MethodDescriptor *method;
::google::protobuf::RpcController *controller;
const ::google::protobuf::Message *request;
::google::protobuf::Message *response;
::google::protobuf::Closure *done;
} RpcCall;
QList<RpcCall> pendingCallList;
QHostAddress mServerAddress;
quint16 mServerPort;
QTcpSocket *mpSocket;
public:
PbRpcChannel(QHostAddress ip, quint16 port);
~PbRpcChannel();
void establish();
void establish(QHostAddress ip, quint16 port);
void tearDown();
const QHostAddress& serverAddress() const { return mServerAddress; }
quint16 serverPort() const { return mServerPort; }
QAbstractSocket::SocketState state() const
{ return mpSocket->state(); }
void CallMethod(const ::google::protobuf::MethodDescriptor *method,
::google::protobuf::RpcController *controller,
const ::google::protobuf::Message *req,
::google::protobuf::Message *response,
::google::protobuf::Closure* done);
signals:
void connected();
void disconnected();
void error(QAbstractSocket::SocketError socketError);
void stateChanged(QAbstractSocket::SocketState socketState);
private slots:
void on_mpSocket_connected();
void on_mpSocket_disconnected();
void on_mpSocket_stateChanged(QAbstractSocket::SocketState socketState);
void on_mpSocket_error(QAbstractSocket::SocketError socketError);
void on_mpSocket_readyRead();
};
#endif