X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FService.hh;h=77cee183f9b3346c8563dbafff75105b00e9ee76;hp=5870d576b454717217a4da1e18efee8abf58a24a;hb=3fd6f206f0e64122b7cb289907a1a780b6ed2dc9;hpb=41f8dd670e963aad94527ce2be0486268993a477 diff --git a/src/Moof/Service.hh b/src/Moof/Service.hh index 5870d57..77cee18 100644 --- a/src/Moof/Service.hh +++ b/src/Moof/Service.hh @@ -9,32 +9,97 @@ * **************************************************************************/ +/** + * \file Service.hh + * Classes for publishing and finding network services. + */ + #ifndef _MOOF_SERVICE_HH_ #define _MOOF_SERVICE_HH_ +#include + #include +#include namespace Mf { -class ServiceBroadcaster +/** + * Class representing a network service. + */ +class Service { public: - ServiceBroadcaster(const std::string& name); + /** + * Construct a network service. + * \param address The address of the host. + * \param text The service information. + */ + Service(const SocketAddress& address, const std::string& text); + + + /** + * Publish the service on the local network. + */ + void publish(); + + void stop(); + + + /** + * Get the host address. + * \return The address. + */ + const SocketAddress& address() const + { + return mAddress; + } + + /** + * Get the service information. + * \return The service information as a string. + */ + const std::string& text() const + { + return mText; + } - void update(Scalar t, Scalar dt); + +private: + + int handlePacket(SocketMultiplexer& sock, + Packet& packet, + const SocketAddress& address); + + SocketAddress mAddress; + std::string mText; }; -class ServiceLocator +class ServiceFinder { public: - ServiceLocator(const std::string& name); + ServiceFinder(const std::string& service, int type = SOCK_STREAM); + + + const std::vector& services() const + { + return mServices; + } + + +private: + + int handlePacket(SocketMultiplexer& sock, + Packet& packet, + const SocketAddress& address); - void update(Scalar t, Scalar dt); + std::string mService; + std::vector mServices; };