Sleds/cppcore/cppcore-test/concreteobserver.h

94 lines
3.6 KiB
C++

// Copyright (c) 2014, IOnU Security Inc.
#ifndef CONCRETE_OBSERVER
#define CONCRETE_OBSERVER
#include "../client/peerobserver.h"
class ConcreteObserver : public sequencelogic::PeerObserver
{
public:
////// Observer must cough up a directory for storing limited unencrypted work data
virtual std::string getWorkingDirectory();
////// SyncAndMessageDispatch / PubSub initiated
/**
* Invoked when a new message was received.
*/
virtual void onSubscribedMessageReceived(const std::string &msg);
/**
* Invoked by PeerOutboundThread when a reply message was sent.
* Typically observer has little work to perform, other than perhaps doing some UX status updating.
* @param msg
*/
virtual void onResponseSent(const std::string &msg);
/**
* Called when message is disposed.
* @param fm
*/
virtual void onMessageDisposed(const std::string &msg);
/**
* Incoming subscribed messages that require manual user reply/action will fire this method from the peer
* system after the message is persisted.
* @param msg
*/
virtual void onMessagePersisted(const std::string &msg);
/**
* Called when message is removed.
* @param msg
*/
virtual void onMessageRemoved(const std::string &msg);
/**
* Normally PubSubMessages that return true when isManualUserReplyRequired is invoked
* require manual user intervention. This observer method allows an automatic "bot" reply
* to those normally manual reply messages.
* @param msg An isManualUserReplyRequired message
* @param reply A reply message to msg; the responseData will need to be indicated by observer
* @return null if normal message persistence is required; non-null reply object if a "bot" reply
* is desired
*
* @return A JSON string to reply to the message with. We will take ownership of the memory.
*/
virtual std::string automaticReplyToManualMessage(const std::string &msg, const std::string &reply);
//////// SAMD internal
virtual void onInactivityTimeReached();
//////// StorageGuardService initiated
virtual void onSyncStart(const std::string &node);
virtual void onSyncComplete(const std::string &node);
virtual void onSyncError(const std::string &node, const std::string &ex);
virtual void onSyncUploaded(const std::string &eye);
virtual void onSyncDownload(const std::string &eye);
virtual void onSyncDelete(const std::string &path);
//////// SAMD messages...
/**
* Notify the client that sync and message dispatch is starting.
*
* @param pUrn The device URN that is being sync'd
*/
virtual void onSyncAndDispatchStart(const std::string &urn);
/**
* Notify the client that sync and message dispatch has ended.
*
* @param pUrn The device URN that is being sync'd
*/
virtual void onSyncAndDispatchStop(const std::string &urn);
//////// State and Errors
/**
* Was in an error (disconnected) state and now connected again.
* @return false to skip internal sync logic; true to internally invoke subscribe
*/
virtual bool onConnectionRestored();
virtual void onFatalError(int code, const std::string &msg);
virtual void onServiceException(const std::string &urlOrIdentifier, const std::string &ex);
};
#endif