[DEV] binary transmission start to work

This commit is contained in:
Edouard DUPIN 2016-06-13 22:15:06 +02:00
parent b89cb3198c
commit bb3858625f
8 changed files with 2090 additions and 443 deletions

File diff suppressed because it is too large Load Diff

View File

@ -155,8 +155,13 @@ namespace jus {
const uint8_t* getParameterPointer(int32_t _id) const;
uint32_t getParameterSize(int32_t _id) const;
private:
// add parameter for transcription of json element
void addParameter(ejson::Value _value);
public:
template<class JUS_TYPE_DATA>
void addParameter(const JUS_TYPE_DATA& _value);
void addParameterEmptyVector();
void addParameter();
template<class JUS_TYPE_DATA>
@ -179,10 +184,15 @@ namespace jus {
return internalGetParameter<JUS_TYPE_DATA>(0);
}
void addError(const std::string& _value, const std::string& _comment);
bool hasError();
std::string getError();
std::string getErrorHelp();
void prepare();
ejson::Object toJson() const;
void fromJson(const ejson::Object& _data);
void fromJson(const std::string& _data);
};
std::ostream& operator <<(std::ostream& _os, enum jus::Buffer::typeMessage _value);

View File

@ -15,202 +15,132 @@ namespace jus {
if (m_data == nullptr) {
return false;
}
// JSON mode
if (m_data->m_mode == false) {
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
JUS_WARNING("No Return value ...");
return false;
}
if (val.isBoolean() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Boolean'");
return false;
}
return val.toBoolean().get();
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return false;
}
// binary mode:
return m_data->m_returnDataBinary.getAnswer<bool>();
return m_data->m_returnData.getAnswer<bool>();
}
template<>
int64_t jus::Future<int64_t>::get() {
if (m_data == nullptr) {
return 0;
}
// JSON mode
if (m_data->m_mode == false) {
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return int64_t(val.toNumber().get());
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
// binary mode:
return m_data->m_returnDataBinary.getAnswer<bool>();
return m_data->m_returnData.getAnswer<bool>();
}
template<>
int32_t jus::Future<int32_t>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return int32_t(val.toNumber().get());
return m_data->m_returnData.getAnswer<int32_t>();
}
template<>
int16_t jus::Future<int16_t>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return int16_t(val.toNumber().get());
return m_data->m_returnData.getAnswer<int16_t>();
}
template<>
int8_t jus::Future<int8_t>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return int8_t(val.toNumber().get());
return m_data->m_returnData.getAnswer<int8_t>();
}
template<>
uint64_t jus::Future<uint64_t>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return uint64_t(val.toNumber().get());
return m_data->m_returnData.getAnswer<int64_t>();
}
template<>
uint32_t jus::Future<uint32_t>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return uint32_t(val.toNumber().get());
return m_data->m_returnData.getAnswer<uint32_t>();
}
template<>
uint16_t jus::Future<uint16_t>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return uint16_t(val.toNumber().get());
return m_data->m_returnData.getAnswer<uint16_t>();
}
template<>
uint8_t jus::Future<uint8_t>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0;
}
return uint8_t(val.toNumber().get());
return m_data->m_returnData.getAnswer<uint8_t>();
}
template<>
double jus::Future<double>::get() {
if (m_data == nullptr) {
return 0;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0.0;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0.0;
}
return val.toNumber().get();
return m_data->m_returnData.getAnswer<double>();
}
template<>
float jus::Future<float>::get() {
if (m_data == nullptr) {
return 0.0f;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return 0.0f;
}
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Number'");
return 0.0f;
}
return val.toNumber().get();
return m_data->m_returnData.getAnswer<float>();
}
template<>
std::string jus::Future<std::string>::get() {
if (m_data == nullptr) {
return "";
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return "";
}
if (val.isString() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'String'");
return "";
}
return val.toString().get();
return m_data->m_returnData.getAnswer<std::string>();
}
template<>
std::vector<int64_t> jus::Future<std::vector<int64_t>>::get() {
@ -218,22 +148,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(int64_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<int64_t>>();
return out;
}
template<>
@ -242,22 +161,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(int32_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<int32_t>>();
return out;
}
template<>
@ -266,22 +174,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(int16_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<int16_t>>();
return out;
}
template<>
@ -290,22 +187,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(int8_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<int8_t>>();
return out;
}
template<>
@ -314,22 +200,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(uint64_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<uint64_t>>();
return out;
}
template<>
@ -338,22 +213,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(uint32_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<uint32_t>>();
return out;
}
template<>
@ -362,22 +226,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(int16_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<uint16_t>>();
return out;
}
template<>
@ -386,22 +239,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (val.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(uint8_t(val.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<uint8_t>>();
return out;
}
template<>
@ -410,22 +252,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (it.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(it.toNumber().get());
}
out = m_data->m_returnData.getAnswer<std::vector<double>>();
return out;
}
template<>
@ -434,22 +265,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (it.isNumber() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Number'");
continue;
}
out.push_back(float(it.toNumber().get()));
}
out = m_data->m_returnData.getAnswer<std::vector<float>>();
return out;
}
template<>
@ -458,22 +278,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (it.isString() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'String'");
continue;
}
out.push_back(it.toString().get());
}
out = m_data->m_returnData.getAnswer<std::vector<std::string>>();
return out;
}
template<>
@ -482,22 +291,11 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
JUS_WARNING("No Return value ...");
return out;
}
if (val.isArray() == false) {
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Array'");
return out;
}
for (auto it : val.toArray()) {
if (it.isBoolean() == false) {
JUS_WARNING("Wrong return Type (part of array) get '" << it.getType() << " instead of 'Boolean'");
continue;
}
out.push_back(it.toBoolean().get());
}
out = m_data->m_returnData.getAnswer<std::vector<bool>>();
return out;
}
template<>
@ -506,6 +304,7 @@ namespace jus {
if (m_data == nullptr) {
return out;
}
/* TODO : ...
ejson::Value val = m_data->m_returnData["return"];
if (val.exist() == false) {
JUS_WARNING("No Return value ...");
@ -532,6 +331,7 @@ namespace jus {
out.setData(offset, tmpData);
offset += tmpData.size();
}
*/
return out;
}
}

View File

@ -25,13 +25,13 @@ jus::FutureBase::FutureBase(uint64_t _transactionId, jus::FutureData::ObserverFi
m_data->m_transactionId = _transactionId;
m_data->m_isFinished = false;
m_data->m_isSynchronous = false;
m_data->m_mode = false;
m_data->m_callbackFinish = _callback;
}
ejson::Object jus::FutureBase::getRaw() {
const jus::Buffer& jus::FutureBase::getRaw() {
if (m_data == nullptr) {
return ejson::Object();
static jus::Buffer tmpp;
return tmpp;
}
return m_data->m_returnData;
}
@ -45,8 +45,7 @@ jus::FutureBase::FutureBase(uint64_t _transactionId, bool _isFinished, ejson::Ob
m_data->m_transactionId = _transactionId;
m_data->m_isFinished = _isFinished;
m_data->m_isSynchronous = false;
m_data->m_mode = false;
m_data->m_returnData = _returnData;
m_data->m_returnData.fromJson(_returnData);
m_data->m_callbackFinish = _callback;
if (m_data->m_isFinished == true) {
m_data->m_receiveTime = std::chrono::steady_clock::now();
@ -65,8 +64,7 @@ jus::FutureBase::FutureBase(uint64_t _transactionId, bool _isFinished, jus::Buff
m_data->m_transactionId = _transactionId;
m_data->m_isFinished = _isFinished;
m_data->m_isSynchronous = false;
m_data->m_mode = true;
m_data->m_returnDataBinary = _returnData;
m_data->m_returnData = _returnData;
m_data->m_callbackFinish = _callback;
if (m_data->m_isFinished == true) {
m_data->m_receiveTime = std::chrono::steady_clock::now();
@ -91,54 +89,18 @@ jus::FutureBase jus::FutureBase::operator= (const jus::FutureBase& _base) {
}
bool jus::FutureBase::setAnswer(const ejson::Object& _returnValue) {
if (m_data == nullptr) {
JUS_ERROR(" Not a valid future ...");
return true;
}
m_data->m_mode = false;
m_data->m_receiveTime = std::chrono::steady_clock::now();
if (m_data->m_isSynchronous == true) {
m_data->m_returnData = _returnValue;
if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this);
}
return true;
}
if (_returnValue.valueExist("part") == true) {
uint64_t idPart = _returnValue["part"].toNumber().getU64();
if (idPart == 0) {
m_data->m_returnData = _returnValue;
} else {
m_data->m_returnDataPart.push_back(_returnValue["data"]);
}
if (_returnValue.valueExist("finish") == true) {
if (_returnValue["finish"].toBoolean().get() == true) {
m_data->m_isFinished = true;
if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this);
}
return true;
}
// finish is false ==> normal case ...
}
return false;
}
m_data->m_returnData = _returnValue;
m_data->m_isFinished = true;
if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this);
}
return true;
jus::Buffer tmp;
tmp.fromJson(_returnValue);
return setAnswer(tmp);
}
bool jus::FutureBase::setAnswer(const jus::Buffer& _returnValue) {
if (m_data == nullptr) {
JUS_ERROR(" Not a valid future ...");
return true;
}
m_data->m_mode = true;
m_data->m_receiveTime = std::chrono::steady_clock::now();
if (m_data->m_isSynchronous == true) {
m_data->m_returnDataBinary = _returnValue;
m_data->m_returnData = _returnValue;
if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this);
}
@ -164,7 +126,7 @@ bool jus::FutureBase::setAnswer(const jus::Buffer& _returnValue) {
}
return false;
}*/
m_data->m_returnDataBinary = _returnValue;
m_data->m_returnData = _returnValue;
m_data->m_isFinished = true;
if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this);
@ -189,21 +151,21 @@ bool jus::FutureBase::hasError() {
if (m_data == nullptr) {
return true;
}
return m_data->m_returnData.valueExist("error");
return m_data->m_returnData.hasError();
}
std::string jus::FutureBase::getErrorType() {
if (m_data == nullptr) {
return "NULL_PTR";
}
return m_data->m_returnData["error"].toString().get();
return m_data->m_returnData.getError();
}
std::string jus::FutureBase::getErrorHelp() {
if (m_data == nullptr) {
return "Thsi is a nullptr future";
}
return m_data->m_returnData["error-help"].toString().get();
return m_data->m_returnData.getErrorHelp();
}
bool jus::FutureBase::isValid() {

View File

@ -30,7 +30,7 @@ namespace jus {
FutureBase& wait();
FutureBase& waitFor(std::chrono::microseconds _delta = std::chrono::seconds(30));
FutureBase& waitUntil(std::chrono::steady_clock::time_point _endTime);
ejson::Object getRaw();
const jus::Buffer& getRaw();
std::chrono::nanoseconds getTransmitionTime();
};
class FutureCall {

View File

@ -19,9 +19,7 @@ namespace jus {
uint64_t m_transactionId;
bool m_isSynchronous;
bool m_isFinished;
bool m_mode;
ejson::Object m_returnData;
jus::Buffer m_returnDataBinary;
jus::Buffer m_returnData;
std::vector<ejson::Value> m_returnDataPart;
ObserverFinish m_callbackFinish;
std::chrono::steady_clock::time_point m_sendTime;

View File

@ -372,6 +372,17 @@ void jus::GateWayClient::onClientDataRaw(jus::Buffer& _value) {
callActionForward(m_listConnectedService[serviceId],
_value,
[=](jus::FutureBase _ret) {
// TODO : Check if it is a JSON or binary ...
jus::Buffer tmpp = _ret.getRaw();
JUS_DEBUG(" ==> transmit : " << tmpp.getTransactionId() << " -> " << transactionId);
JUS_DEBUG(" msg=" << tmpp.generateHumanString());
tmpp.setTransactionId(transactionId);
JUS_DEBUG("transmit=" << tmpp.generateHumanString());
m_interfaceClient.writeBinary(tmpp);
// multiple send element ...
return tmpp.getPartFinish();
/*
// TODO : Check if it is a JSON or binary ...
ejson::Object tmpp = _ret.getRaw();
JUS_VERBOSE(" ==> transmit : " << tmpp["id"].toNumber().getU64() << " -> " << transactionId);
@ -387,6 +398,7 @@ void jus::GateWayClient::onClientDataRaw(jus::Buffer& _value) {
return false;
}
return true;
*/
});
}
}
@ -395,6 +407,11 @@ void jus::GateWayClient::onClientDataRaw(jus::Buffer& _value) {
void jus::GateWayClient::onClientData(std::string _value) {
JUS_DEBUG("On data: " << _value);
jus::Buffer tmp;
tmp.fromJson(_value);
onClientDataRaw(tmp);
#ifdef SDFGSDFSFDSFSDFSDF
ejson::Object data(_value);
uint64_t transactionId = data["id"].toNumber().getU64();
if (transactionId == 0) {
@ -699,6 +716,7 @@ void jus::GateWayClient::onClientData(std::string _value) {
}
}
}
#endif
}
jus::FutureBase jus::GateWayClient::callActionForward(uint64_t _callerId,
@ -743,6 +761,7 @@ jus::FutureBase jus::GateWayClient::callBinary(uint64_t _callerId,
std::unique_lock<std::mutex> lock(m_mutex);
m_pendingCall.push_back(std::make_pair(_clientTransactionId, tmpFuture));
}
_obj.setTransactionId(_transactionId);
_srv->SendData(_callerId, _obj);
JUS_VERBOSE("Send BINARY [STOP]");
return tmpFuture;

View File

@ -86,6 +86,7 @@ int main(int _argc, const char *_argv[]) {
APPL_INFO("serviceTest1.mul = " << retCall);
}
*/
if (true) {
APPL_INFO(" ----------------------------------");
APPL_INFO(" -- Get service system-user");
@ -139,59 +140,60 @@ int main(int _argc, const char *_argv[]) {
APPL_INFO(" ----------------------------------");
APPL_INFO(" -- Get service picture");
APPL_INFO(" ----------------------------------");
jus::ServiceRemote remoteServicePicture = client1.getService("picture");
if (remoteServicePicture.exist() == true) {
/*
jus::Future<std::vector<std::string>> retCall = remoteServicePicture.call("getAlbums").wait();
APPL_INFO(" album list: ");
for (auto &it : retCall.get()) {
jus::Future<uint32_t> retCount = remoteServicePicture.call("getAlbumCount", it).wait();
if (retCount.get() != 0) {
APPL_INFO(" - " << it << " / " << retCount.get() << " images");
jus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it).wait();
for (auto &it3 : retListImage.get()) {
APPL_INFO(" - " << it3);
}
} else {
APPL_INFO(" - " << it);
}
jus::Future<std::vector<std::string>> retCall2 = remoteServicePicture.call("getSubAlbums", it).wait();
for (auto &it2 : retCall2.get()) {
jus::Future<uint32_t> retCount2 = remoteServicePicture.call("getAlbumCount", it2).wait();
if (retCount2.get() != 0) {
APPL_INFO(" - " << it2 << " / " << retCount2.get() << " images");
jus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it2).wait();
if (false) {
jus::ServiceRemote remoteServicePicture = client1.getService("picture");
if (remoteServicePicture.exist() == true) {
/*
jus::Future<std::vector<std::string>> retCall = remoteServicePicture.call("getAlbums").wait();
APPL_INFO(" album list: ");
for (auto &it : retCall.get()) {
jus::Future<uint32_t> retCount = remoteServicePicture.call("getAlbumCount", it).wait();
if (retCount.get() != 0) {
APPL_INFO(" - " << it << " / " << retCount.get() << " images");
jus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it).wait();
for (auto &it3 : retListImage.get()) {
APPL_INFO(" - " << it3);
jus::Future<jus::File> retListImage = remoteServicePicture.call("getAlbumPicture", it3).wait();
jus::File tmpFile = retListImage.get();
APPL_INFO(" mine-type: " << tmpFile.getMineType());
APPL_INFO(" size: " << tmpFile.getData().size());
APPL_INFO(" receive in =" << int64_t(retListImage.getTransmitionTime().count()/1000)/1000.0 << " ms");
std::string tmpFileName = std::string("./out/") + it + "_" + it2 + "_" + it3 + "." + jus::getExtention(tmpFile.getMineType());
APPL_INFO(" store in: " << tmpFileName);
etk::FSNode node(tmpFileName);
node.fileOpenWrite();
node.fileWrite(&tmpFile.getData()[0], 1, tmpFile.getData().size());
node.fileClose();
}
} else {
APPL_INFO(" - " << it2);
APPL_INFO(" - " << it);
}
jus::Future<std::vector<std::string>> retCall2 = remoteServicePicture.call("getSubAlbums", it).wait();
for (auto &it2 : retCall2.get()) {
jus::Future<uint32_t> retCount2 = remoteServicePicture.call("getAlbumCount", it2).wait();
if (retCount2.get() != 0) {
APPL_INFO(" - " << it2 << " / " << retCount2.get() << " images");
jus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it2).wait();
for (auto &it3 : retListImage.get()) {
APPL_INFO(" - " << it3);
jus::Future<jus::File> retListImage = remoteServicePicture.call("getAlbumPicture", it3).wait();
jus::File tmpFile = retListImage.get();
APPL_INFO(" mine-type: " << tmpFile.getMineType());
APPL_INFO(" size: " << tmpFile.getData().size());
APPL_INFO(" receive in =" << int64_t(retListImage.getTransmitionTime().count()/1000)/1000.0 << " ms");
std::string tmpFileName = std::string("./out/") + it + "_" + it2 + "_" + it3 + "." + jus::getExtention(tmpFile.getMineType());
APPL_INFO(" store in: " << tmpFileName);
etk::FSNode node(tmpFileName);
node.fileOpenWrite();
node.fileWrite(&tmpFile.getData()[0], 1, tmpFile.getData().size());
node.fileClose();
}
} else {
APPL_INFO(" - " << it2);
}
}
}
*/
#if 0
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
jus::File tmp("./photo_2016_33913.bmp");//"image/jpg", {0,5,2,6,7,5,8,4,5,2,1,5,65,5,2,6,85,4,6,6,54,65,88,64,14,6,4,64,51,3,16,4});
int32_t size = tmp.getData().size();
jus::FutureBase retSendImage = remoteServicePicture.call("addFile", tmp).wait();
std::chrono::steady_clock::time_point stop = std::chrono::steady_clock::now();
APPL_WARNING(" IO*=" << int64_t((stop-start).count()/1000)/1000.0 << " ms");
double megaParSec = double(size)/(double((stop-start).count())/1000000000.0);
APPL_WARNING(" speed=" << int64_t(megaParSec/1024.0)/1024.0 << " Mo/s");
#endif
}
*/
#if 0
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
jus::File tmp("./photo_2016_33913.bmp");//"image/jpg", {0,5,2,6,7,5,8,4,5,2,1,5,65,5,2,6,85,4,6,6,54,65,88,64,14,6,4,64,51,3,16,4});
int32_t size = tmp.getData().size();
jus::FutureBase retSendImage = remoteServicePicture.call("addFile", tmp).wait();
std::chrono::steady_clock::time_point stop = std::chrono::steady_clock::now();
APPL_WARNING(" IO*=" << int64_t((stop-start).count()/1000)/1000.0 << " ms");
double megaParSec = double(size)/(double((stop-start).count())/1000000000.0);
APPL_WARNING(" speed=" << int64_t(megaParSec/1024.0)/1024.0 << " Mo/s");
#endif
}
int32_t iii=0;
while (iii < 3) {