Infra: Added code to disable notifications for python-ostinato scripts since python-ostinato does not expect and hence does not know how to deal with notifications
Updates issue 144
This commit is contained in:
parent
f1378965ca
commit
25ef8dd1e4
@ -43,6 +43,7 @@ class DroneProxy(object):
|
||||
def connect(self):
|
||||
self.channel.connect(self.host, self.port)
|
||||
ver = ost_pb.VersionInfo()
|
||||
ver.client_name = 'python-ostinato'
|
||||
ver.version = __version__
|
||||
compat = self.checkVersion(ver)
|
||||
if compat.result == ost_pb.VersionCompatibility.kIncompatible:
|
||||
|
@ -131,6 +131,7 @@ void PortGroup::on_rpcChannel_connected()
|
||||
reconnectAfter = kMinReconnectWaitTime;
|
||||
|
||||
qDebug("requesting version check ...");
|
||||
verInfo->set_client_name("ostinato");
|
||||
verInfo->set_version(version);
|
||||
|
||||
PbRpcController *controller = new PbRpcController(verInfo, verCompat);
|
||||
|
@ -23,6 +23,7 @@ option py_generic_services = true;
|
||||
|
||||
message VersionInfo {
|
||||
required string version = 1;
|
||||
optional string client_name = 2;
|
||||
}
|
||||
|
||||
message VersionCompatibility {
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
void Reset() {
|
||||
failed = false;
|
||||
disconnect = false;
|
||||
notif = true;
|
||||
blob = NULL;
|
||||
errStr = "";
|
||||
}
|
||||
@ -70,6 +71,12 @@ public:
|
||||
bool Disconnect() const {
|
||||
return disconnect;
|
||||
}
|
||||
void EnableNotif(bool enabled) {
|
||||
notif = enabled;
|
||||
}
|
||||
bool NotifEnabled() {
|
||||
return notif;
|
||||
}
|
||||
|
||||
// srivatsp added
|
||||
QIODevice* binaryBlob() { return blob; };
|
||||
@ -78,6 +85,7 @@ public:
|
||||
private:
|
||||
bool failed;
|
||||
bool disconnect;
|
||||
bool notif;
|
||||
QIODevice *blob;
|
||||
QString errStr;
|
||||
::google::protobuf::Message *request_;
|
||||
|
@ -52,6 +52,7 @@ RpcConnection::RpcConnection(int socketDescriptor,
|
||||
pendingMethodId = -1; // don't care as long as isPending is false
|
||||
|
||||
isCompatCheckDone = false;
|
||||
isNotifEnabled = true;
|
||||
}
|
||||
|
||||
RpcConnection::~RpcConnection()
|
||||
@ -183,8 +184,10 @@ void RpcConnection::sendRpcReply(PbRpcController *controller)
|
||||
response->SerializeToZeroCopyStream(outStream);
|
||||
outStream->Flush();
|
||||
|
||||
if (pendingMethodId == 15)
|
||||
if (pendingMethodId == 15) {
|
||||
isCompatCheckDone = true;
|
||||
isNotifEnabled = controller->NotifEnabled();
|
||||
}
|
||||
|
||||
_exit:
|
||||
if (controller->Disconnect())
|
||||
@ -201,6 +204,12 @@ void RpcConnection::sendNotification(int notifType,
|
||||
char* const msg = &msgBuf[0];
|
||||
int len;
|
||||
|
||||
if (!isCompatCheckDone)
|
||||
return;
|
||||
|
||||
if (!isNotifEnabled)
|
||||
return;
|
||||
|
||||
if (!notifData->IsInitialized())
|
||||
{
|
||||
qWarning("notification missing required fields!! <----");
|
||||
|
@ -77,6 +77,7 @@ private:
|
||||
int pendingMethodId;
|
||||
|
||||
bool isCompatCheckDone;
|
||||
bool isNotifEnabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -574,6 +574,8 @@ void MyService::checkVersion(::google::protobuf::RpcController* controller,
|
||||
// Compare only major and minor numbers
|
||||
if (client[0] == my[0] && client[1] == my[1]) {
|
||||
response->set_result(OstProto::VersionCompatibility::kCompatible);
|
||||
static_cast<PbRpcController*>(controller)->EnableNotif(
|
||||
request->client_name() == "python-ostinato" ? false : true);
|
||||
}
|
||||
else {
|
||||
response->set_result(OstProto::VersionCompatibility::kIncompatible);
|
||||
|
Loading…
Reference in New Issue
Block a user