ui: plugin ping

added update pings on token activation (just to have a somewhat regularly reoccuring event to trigger the ping)
This commit is contained in:
wrongway88
2017-02-16 20:30:22 +01:00
parent 50df7cace2
commit ed9ff6d1bc
3 changed files with 33 additions and 5 deletions
@@ -71,7 +71,7 @@ void IDECommunicationController::setEnabled(const bool enabled)
void IDECommunicationController::sendInitialPing()
{
sendMessage(NetworkProtocolHelper::buildPingMessage());
sendUpdatePing();
}
void IDECommunicationController::handleSetActiveTokenMessage(
@@ -179,11 +179,12 @@ void IDECommunicationController::handlePing(const NetworkProtocolHelper::PingMes
if (msg.ideId == "vs")
{
ideName = "Visual Studio";
msg.ideName = ideName;
ideName = "Visual Studio";
}
// TODO: add the other ides
msg.ideName = ideName;
std::string statusMessage = ideName + " instance detected via plugin port";
MessageStatus(statusMessage, false, false).dispatch();
@@ -195,6 +196,11 @@ void IDECommunicationController::handlePing(const NetworkProtocolHelper::PingMes
}
}
void IDECommunicationController::handleMessage(MessageActivateTokens* message)
{
sendUpdatePing();
}
void IDECommunicationController::handleMessage(MessageIDECreateCDB* message)
{
std::string networkMessage = NetworkProtocolHelper::buildCreateCDBMessage();
@@ -223,3 +229,15 @@ void IDECommunicationController::handleMessage(MessagePluginPortChange* message)
stopListening();
startListening();
}
void IDECommunicationController::sendUpdatePing()
{
// first reset connection status
MessagePingReceived msg;
msg.ideId = "";
msg.ideName = "";
msg.dispatch();
// send ping to update connection status
sendMessage(NetworkProtocolHelper::buildPingMessage());
}
@@ -7,6 +7,7 @@
#include "component/controller/helper/NetworkProtocolHelper.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageActivateTokens.h"
#include "utility/messaging/type/MessageIDECreateCDB.h"
#include "utility/messaging/type/MessageMoveIDECursor.h"
#include "utility/messaging/type/MessagePluginPortChange.h"
@@ -15,6 +16,7 @@ class StorageAccess;
class IDECommunicationController
: public Controller
, public MessageListener<MessageActivateTokens>
, public MessageListener<MessageIDECreateCDB>
, public MessageListener<MessageMoveIDECursor>
, public MessageListener<MessagePluginPortChange>
@@ -43,11 +45,14 @@ private:
void handleCreateCDBProjectMessage(const NetworkProtocolHelper::CreateCDBProjectMessage& message);
void handlePing(const NetworkProtocolHelper::PingMessage& message);
virtual void handleMessage(MessageActivateTokens* message); // use this to send update pings
virtual void handleMessage(MessageIDECreateCDB* message);
virtual void handleMessage(MessageMoveIDECursor* message);
virtual void handleMessage(MessagePluginPortChange* message);
virtual void sendMessage(const std::string& message) const = 0;
void sendUpdatePing();
StorageAccess* m_storageAccess;
bool m_enabled;
@@ -37,8 +37,13 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message)
void StatusBarController::handleMessage(MessagePingReceived* message)
{
std::string status = "Connected to ";
status += message->ideName;
std::string status = "No IDE connected";
if (message->ideName.length() > 0)
{
status = "Connected to ";
status += message->ideName;
}
getView()->showIdeStatus(status);
}