- enum ProxyMode {
- Server,
- Client
- };
-
- enum RequestType {
- Sync = 1,
- RpcCall,
- InitRequest,
- InitData,
- HeartBeat,
- HeartBeatReply
- };
-
- enum ClientConnectionType {
- SignalProxyConnection,
- IODeviceConnection
- };
-
- enum CustomEvents {
- PeerSignal = QEvent::User,
- RemovePeer
- };
-
- SignalProxy(QObject *parent);
- SignalProxy(ProxyMode mode, QObject *parent);
- SignalProxy(ProxyMode mode, QIODevice *device, QObject *parent);
- virtual ~SignalProxy();
-
- void setProxyMode(ProxyMode mode);
- inline ProxyMode proxyMode() const { return _proxyMode; }
-
- bool addPeer(QIODevice *iodev);
- bool addPeer(SignalProxy *proxy);
- void removePeer(QObject *peer);
- void removeAllPeers();
-
- bool attachSignal(QObject *sender, const char *signal, const QByteArray& sigName = QByteArray());
- bool attachSlot(const QByteArray& sigName, QObject *recv, const char *slot);
-
- void synchronize(SyncableObject *obj);
- void stopSynchronize(SyncableObject *obj);
-
- //! Writes a QVariant to a device.
- /** The data item is prefixed with the resulting blocksize,
- * so the corresponding function readDataFromDevice() can check if enough data is available
- * at the device to reread the item.
- */
- static void writeDataToDevice(QIODevice *dev, const QVariant &item, bool compressed = false);
-
- //! Reads a data item from a device that has been written by writeDataToDevice().
- /** If not enough data bytes are available, the function returns false and the QVariant reference
- * remains untouched.
- */
- static bool readDataFromDevice(QIODevice *dev, quint32 &blockSize, QVariant &item, bool compressed = false);
-
- class ExtendedMetaObject;
- ExtendedMetaObject *extendedMetaObject(const QMetaObject *meta) const;
- ExtendedMetaObject *createExtendedMetaObject(const QMetaObject *meta, bool checkConflicts = false);
- inline ExtendedMetaObject *extendedMetaObject(const QObject *obj) const { return extendedMetaObject(metaObject(obj)); }
- inline ExtendedMetaObject *createExtendedMetaObject(const QObject *obj, bool checkConflicts = false) { return createExtendedMetaObject(metaObject(obj), checkConflicts); }
-
- bool isSecure() const { return _secure; }
- void dumpProxyStats();
+ enum ProxyMode {
+ Server,
+ Client
+ };
+
+ enum EventType {
+ RemovePeerEvent = QEvent::User
+ };
+
+ SignalProxy(QObject *parent);
+ SignalProxy(ProxyMode mode, QObject *parent);
+ virtual ~SignalProxy();
+
+ void setProxyMode(ProxyMode mode);
+ inline ProxyMode proxyMode() const { return _proxyMode; }
+
+ void setHeartBeatInterval(int secs);
+ inline int heartBeatInterval() const { return _heartBeatInterval; }
+ void setMaxHeartBeatCount(int max);
+ inline int maxHeartBeatCount() const { return _maxHeartBeatCount; }
+
+ bool addPeer(Peer *peer);
+
+ bool attachSignal(QObject *sender, const char *signal, const QByteArray &sigName = QByteArray());
+ bool attachSlot(const QByteArray &sigName, QObject *recv, const char *slot);
+
+ void synchronize(SyncableObject *obj);
+ void stopSynchronize(SyncableObject *obj);
+
+ class ExtendedMetaObject;
+ ExtendedMetaObject *extendedMetaObject(const QMetaObject *meta) const;
+ ExtendedMetaObject *createExtendedMetaObject(const QMetaObject *meta, bool checkConflicts = false);
+ inline ExtendedMetaObject *extendedMetaObject(const QObject *obj) const { return extendedMetaObject(metaObject(obj)); }
+ inline ExtendedMetaObject *createExtendedMetaObject(const QObject *obj, bool checkConflicts = false) { return createExtendedMetaObject(metaObject(obj), checkConflicts); }
+
+ bool isSecure() const { return _secure; }
+ void dumpProxyStats();
+ void dumpSyncMap(SyncableObject *object);
+ inline int peerCount() const { return _peers.size(); }