JPT Message object
Introduction
Message class is widely used in jpt.Message object is being used in all brower based communication, that means all communications except tracker annoucement will all use this class to transmit information between server and client.
For any client that want to communicate with server, please read this document carefully before implementing your own data receiver.
Format
There are only two kinds of messages, either SUCCESS or FAIL, no more.
The Java class is like
1 | |
I use GSON to serialize the object, so the corresponding JSON will be:
1 | |
On Succeed
For any requests that not only go through the whole procedure without any error, but also achieved what it requested, server will return a message with status=SUCCESS.
1 | |
In some cases, a SUCCESS message will not contain data field. But most of the cases will contain data field with specific data object.
1 | |
For instance, a SUCCESSed request for adding a thread will return the persisted target thread content, in which its related beans like user and parent post will also be embeded.
1 | |
On Failed
For all other cases, server will return a message with status=FAIL.
1 | |
In most of the situation, message with FAIL will not contain data field.
For instance a FAILed request for adding a thread will return the reason of failing the request.
1 | |
Caveat
- If contain data field, there might have nested information embeded in the out-most bean. This is for accelerate the request in case of doing redundant request for directly related bean. For detailed bean structure, please refer to entity.
- All request except
Announcementwill getMessageobject. If you get something else, there must be cracker in between client and server.