[DEV] think new api for binary protocol
This commit is contained in:
parent
4337d20a10
commit
ce5dc052f6
111
jus/Buffer.h
111
jus/Buffer.h
@ -14,19 +14,110 @@ namespace jus {
|
||||
U32 clientID; ==> sevice ID
|
||||
U1 finish part
|
||||
U15 partID;
|
||||
U16 TypeMessgae (1:call, 2:Answer, 4:event)
|
||||
// not needed ==> can be deduced with parameter number ... U16 Offset String call Name (start of the buffer) end with \0
|
||||
U8 param count
|
||||
U16[param count] parameters offset
|
||||
... DATAS ...
|
||||
======================
|
||||
== call
|
||||
======================
|
||||
U16[param count] parameters offset (first offset is the "callName" and limit size of the number of parameter
|
||||
CALL Name (funtion name)
|
||||
[param 1]
|
||||
[param 2]
|
||||
[param 3]
|
||||
[param 4]
|
||||
======================
|
||||
== Answer
|
||||
======================
|
||||
U16 ErrorOffset
|
||||
[return value 1]
|
||||
[error] (constituated with 2 strings (error type and comment)
|
||||
======================
|
||||
== event
|
||||
======================
|
||||
U16[param count] parameters offset (first offset is the "callName" and limit size of the number of parameter
|
||||
event Name
|
||||
[param 1]
|
||||
[param 2]
|
||||
[param 3]
|
||||
[param 4]
|
||||
---------------------------
|
||||
parameter and return value is contituated like :
|
||||
TYPE,DATAs....(in raw)
|
||||
Type is write in ascii in the list end with '\0':
|
||||
- void
|
||||
- bool
|
||||
- float
|
||||
- double
|
||||
- int64
|
||||
- int32
|
||||
- int16
|
||||
- int8
|
||||
- uint64
|
||||
- uint32
|
||||
- uint16
|
||||
- uint8
|
||||
- string
|
||||
- vector:bool
|
||||
- vector:float
|
||||
- vector:double
|
||||
- vector:int64
|
||||
- vector:int32
|
||||
- vector:int16
|
||||
- vector:int8
|
||||
- vector:uint64
|
||||
- vector:uint32
|
||||
- vector:uint16
|
||||
- vector:uint8
|
||||
- vector:string
|
||||
- obj:file
|
||||
*/
|
||||
class Buffer {
|
||||
private:
|
||||
std::vector<uint8_t> m_data;
|
||||
uint64_t m_transactionId;
|
||||
uint64_t m_clientId; // clientId/service
|
||||
uint32_t m_partId;
|
||||
bool m_partFinish;
|
||||
uint32_t m_parameterCount;
|
||||
|
||||
public:
|
||||
Buffer();
|
||||
Buffer();
|
||||
clear();
|
||||
uint16_t getProtocalVersion();
|
||||
void setProtocolVersion(uint16_t _value);
|
||||
uint32_t getTransactionId();
|
||||
void setTransactionId(uint32_t _value);
|
||||
uint32_t getClientId();// this is the same as serviceId
|
||||
void setClientId(uint32_t _value);
|
||||
uint32_t getServiceId() {
|
||||
return getClientId();
|
||||
}
|
||||
void setServiceId(uint32_t _value) {
|
||||
setClientId(_value);
|
||||
}
|
||||
// note limited 15 bits
|
||||
uint16_t getPartId();
|
||||
void setPartId(uint16_t _value);
|
||||
bool getPartFinish();
|
||||
void setPartFinish(bool _value);
|
||||
enum class typeMessage {
|
||||
call = 0x0001,
|
||||
answer = 0x0002,
|
||||
event = 0x0004,
|
||||
}
|
||||
enum typeMessage getType();
|
||||
void setType(enum typeMessage _value);
|
||||
// ===============================================
|
||||
// == Section call
|
||||
// ===============================================
|
||||
public:
|
||||
std::string getCall();
|
||||
void setCall(std::string _value);
|
||||
uint16_t getNumberParameter();
|
||||
|
||||
template<class JUS_TYPE_DATA>
|
||||
void addParameter(const JUS_TYPE_DATA& _value);
|
||||
|
||||
// ===============================================
|
||||
// == Section Answer
|
||||
// ===============================================
|
||||
public:
|
||||
template<class JUS_TYPE_DATA>
|
||||
void addAnswer(const JUS_TYPE_DATA& _value);
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user