// Ivy.h: interface for the Ivy class. // ////////////////////////////////////////////////////////////////////// #pragma once #ifdef WIN32 #ifdef IVY_EXPORTS class _declspec(dllexport) IvyWatcher; class _declspec(dllexport) IvyApplication; class _declspec(dllexport) Ivy; class _declspec(dllexport) CThreadedSocket; class _declspec(dllexport) CBufferedSocket; #else #pragma comment(lib,"Ivy.LIB" ) class _declspec(dllimport) IvyWatcher; class _declspec(dllimport) IvyApplication; class _declspec(dllimport) Ivy; class _declspec(dllimport) CThreadedSocket; class _declspec(dllimport) CBufferedSocket; #endif #endif #include "IvyCallback.h" class IvyWatcher; class IvyApplication; class Ivy { private: unsigned short applicationPort; void SendSubscriptions(IvyApplication *app); public: void AddApplication( IvyApplication *app ); void RemoveApplication( IvyApplication *app); bool CheckConnected( IvyApplication *app ); bool CheckRegexp( const char *exp ); void CallApplicationConnectedCallback( IvyApplication *app ); void CallApplicationDisconnectedCallback( IvyApplication *app ); bool CallDieCallback( IvyApplication *app, int id, const char *arg ); void CallDirectMessageCallback( IvyApplication *app, int id, const char *arg ); void CallMessageCallback( IvyApplication *app, int id, int argc, const char **argv ); public: void Classes( int argc, const char **argv ); void SendDirectMsg( IvyApplication *app, int id, const char *message); void BindDirectMsg( IvyDirectMessageCallback *callback ); int SendMsg( const char *message ); const char *GetDomain(const char *domainlist); unsigned short GetApplicationPort(); int BindMsg( const char *regexp, IvyMessageCallback *cb ); void UnbindMsg( int id ); Ivy( const char *name, const char* ready, IvyApplicationCallback *callback, bool Synchronous = true ); void start(const char *domain); void stop(); virtual ~Ivy(); /* message a emettre sur connection nouvelle application */ string ready_message; protected: bool synchronous; // use Window Shink to made CB mono thread like IvyApplication * server; IvyWatcher * watcher; IvyDieCallback *die_callback; IvyDirectMessageCallback *direct_callback; IvyApplicationCallback *application_callback; /* list des adresses de broadcast */ string domain; /* nom de l'appliction */ string appname; /* liste des clients connectes */ CRITICAL_SECTION m_application_cs; typedef list IvyApplicationList; IvyApplicationList applications; /* liste des souscriptions locale a emettre aux autres applications */ vector regexp_out; /* liste des callbacks a appeler */ vector< IvyMessageCallback* > callbacks; /* classes de messages emis par l'application utilise pour le filtrage */ int messages_classes_count; const char **messages_classes; };