This document has the objective to give you an overview of how to use Palantir in your applications.
Assume you have two users, "Chantal" and "Kevin", who want to communicate through a secured channel. To set up their channel the following has to be done:
- Create User "Kevin" and "Chantal"
- One user has to send a contact request to the other
- The contact request has to be accepted
- They can now chat within their own secure channel
You can have a look at the cucumber tests, the example or read the usecase descriptions to see how things are set up codewise.
The Messenger follows a usecase orientated approach. The code snippets for every usecase reflect how it is used in Chiota.
More information: http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html
- Create User
- Check User
- Add Contact
- Get Contacts
- Accept Contact
- Decline Contact
- Send Message
- Get Messages
Each response of a usecase inherits from a base response that does contain a response code. You can use the response code to display error messages to your users if needed. For further details see the ResponseCode enumeration.
While interactors are in place to orchestrate behaviour, entities are supposed to hold it. For details, just take a look at the Entity folder.
You may notice that there currently is not so much business logic in them. That is a thing that will be addressed iteratively, while refactoring the interactors to be pure orchestrators.
For most modern applications it is not possible to be completely clean of outer dependencies. To handle those, repositories have been put in place, to inverse those dependencies.
The messenger module defines two repositories you have to implement yourself (You could start off with the memory implementations for testing, but they will not get you far)
-
IContactRepository
There are two options to implement this interface:
a) Implement the complete interface to use your own logic
b) Extend the AbstractTangleContactRepository, that already contains basic logic to load contacts from the tangle -
ITransactionCache
This repository caches all transactions received by the messenger. You should implement it in order to significantly speed up your application. In addition cached transactions can not be wiped in a snapshot, which can be useful