Libretroshare services

From RetroShare
Jump to: navigation, search

From a developers perspective, all the retroshare applications are built as services.


Contents

Services: libretroshare/src/services/

Services are Modular Plugins, which can rely on the Lower layers of Retroshare to transport data, connect with peers. Currently we have the following Message Based Services:

  • p3chatservice - Instant Messaging Service. (Easy example to Examine)
  • p3msgservice - Messages (Email) Service
  • p3gamelauncher - Games Service
  • p3disc - Peer Discovery Service


Retroshare also has a series of services which use the internal Cache System:

  • p3ranking - Link Sharing and Ranking Service (Reasonably Simple Cache Based Exaple)
  • p3photoservice - For sharing Photographs (Cache Based)

More information about cache system: Cache system code overview


All of these services are based around the same base class: p3service.h, the basics you can see below:

<source lang="cpp"> class p3Service: public pqiService {

       protected:
   /* These Functions are used to Setup The Service by the Derived Class */
   p3Service(uint16_t type);

void addSerialType(RsSerialType *);

       public:

virtual ~p3Service();

/*************** INTERFACE ******************************/

    /* Mutex Protected Interface, call from Thread/tick/GUI (or anywhere else) to get and send Network messages.
     * Message Source/Destination are determined by RsItem::PeerId()
     */

int sendItem(RsItem *); RsItem * recvItem(); bool receivedItems(); /* any messages available? */

virtual int tick() { return 0; } /* overload this function to do the work in your service */ /*************** INTERFACE ******************************/

   // rest of class ... (removed for clarity)

};

</source>


Support Functions

Any Service can make use of both the Connection Manager and Authentication Manager, to lookup Peer details. Some of functionality these classes provide is:

Authentication Manager

<source lang="cpp"> class p3AuthMgr {

       public:
   // Constructor etc ... (removed for clarity)
   /*********** get Certificate Ids ********/

virtual std::string OwnId() = 0; virtual bool getAllList(std::list<std::string> &ids) = 0; virtual bool getAuthenticatedList(std::list<std::string> &ids) = 0; virtual bool getUnknownList(std::list<std::string> &ids) = 0;

   /****** get Details from the Certificates *****/

virtual bool isValid(std::string id) = 0; virtual bool isAuthenticated(std::string id) = 0; virtual std::string getName(std::string id) = 0; virtual bool getDetails(std::string id, pqiAuthDetails &details) = 0;

   // rest of class ... (removed for clarity)

};


</source>

Connection Manager

<source lang="cpp"> class p3ConnectMgr: public pqiConnectCb, public p3Config {

   public:
   // Constructor etc ... (removed for clarity)
   /*************** External Information ****************/
       /* access to network details (called through Monitor) */

const std::string getOwnId(); bool getOwnNetStatus(peerConnectState &state);

bool isFriend(std::string id); bool getFriendNetStatus(std::string id, peerConnectState &state); bool getOthersNetStatus(std::string id, peerConnectState &state);

void getOnlineList(std::list<std::string> &peers); void getFriendList(std::list<std::string> &peers); void getOthersList(std::list<std::string> &peers);

   // rest of class ... (removed for clarity)

};


</source>

Serialiser: Service Specific Data Transport: libretroshare/src/serialiser

Each Service must define its own Data Types and Serialiser/Deserialiser that it wants to use. These Data Types are derived from RsItem can be constructed from a wide range of TLV base types that have already been encoded.

There are an number of example datatypes in the serialiser directory.

Personal tools
Namespaces

Variants
Actions
Navigation
External websites
Wiki
Toolbox