2016-05-23 21:18:37 +02:00
|
|
|
/** @file
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
|
|
|
* @license APACHE v2.0 (see license file)
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <jus/TcpString.h>
|
|
|
|
#include <eproperty/Value.h>
|
|
|
|
#include <ejson/ejson.h>
|
|
|
|
#include <jus/debug.h>
|
2016-05-26 22:12:37 +02:00
|
|
|
#include <jus/AbstractFunction.h>
|
2016-05-23 21:18:37 +02:00
|
|
|
#include <jus/ServiceRemote.h>
|
2016-05-27 00:08:02 +02:00
|
|
|
#include <jus/Future.h>
|
2016-05-23 21:18:37 +02:00
|
|
|
|
|
|
|
namespace jus {
|
|
|
|
class Client;
|
|
|
|
class ServiceRemote {
|
|
|
|
private:
|
|
|
|
jus::Client* m_clientInterface;
|
|
|
|
std::string m_name;
|
2016-05-25 21:25:33 +02:00
|
|
|
bool m_isLinked;
|
2016-05-23 21:18:37 +02:00
|
|
|
public:
|
|
|
|
ServiceRemote(jus::Client* _clientInterface, const std::string& _name);
|
|
|
|
~ServiceRemote();
|
2016-05-25 21:25:33 +02:00
|
|
|
bool exist();
|
2016-05-23 21:18:37 +02:00
|
|
|
private:
|
2016-05-27 22:21:32 +02:00
|
|
|
jus::FutureBase callJson(uint64_t _transactionId, const ejson::Object& _obj, jus::FutureData::ObserverFinish _callback=nullptr);
|
2016-05-26 22:12:37 +02:00
|
|
|
uint64_t getId();
|
2016-05-23 21:18:37 +02:00
|
|
|
public:
|
|
|
|
template<class... _ARGS>
|
2016-05-27 00:08:02 +02:00
|
|
|
jus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
|
|
|
uint64_t id = getId();
|
2016-05-29 23:59:19 +02:00
|
|
|
ejson::Object callElem = jus::createCallService(id, m_name, _functionName, std::forward<_ARGS>(_args)...);
|
2016-05-27 00:08:02 +02:00
|
|
|
return callJson(id, callElem);
|
2016-05-23 21:18:37 +02:00
|
|
|
}
|
2016-05-27 22:21:32 +02:00
|
|
|
template<class... _ARGS>
|
|
|
|
jus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, jus::FutureData::ObserverFinish _callback) {
|
|
|
|
uint64_t id = getId();
|
2016-05-29 23:59:19 +02:00
|
|
|
ejson::Object callElem = jus::createCallService(id, m_name, _functionName, std::forward<_ARGS>(_args)...);
|
2016-05-27 22:21:32 +02:00
|
|
|
return callJson(id, callElem, _callback);
|
|
|
|
}
|
2016-05-23 21:18:37 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|