zeus/jus/ServiceRemote.cpp

58 lines
1.7 KiB
C++
Raw Normal View History

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)
*/
#include <jus/ServiceRemote.h>
#include <jus/Client.h>
jus::ServiceRemote::ServiceRemote(jus::Client* _clientInterface, const std::string& _name):
m_clientInterface(_clientInterface),
2016-06-08 21:40:42 +02:00
m_name(_name),
m_serviceId(0) {
int32_t val = m_clientInterface->link(_name);
if (val >= 0) {
m_isLinked = true;
m_serviceId = val;
} else {
m_isLinked = false;
m_serviceId = 0;
}
2016-05-23 21:18:37 +02:00
}
jus::ServiceRemote::~ServiceRemote() {
2016-05-25 21:25:33 +02:00
if (m_isLinked == true) {
2016-06-08 21:40:42 +02:00
m_clientInterface->unlink(m_serviceId);
2016-05-25 21:25:33 +02:00
m_isLinked = false;
}
2016-05-23 21:18:37 +02:00
}
2016-05-25 21:25:33 +02:00
bool jus::ServiceRemote::exist() {
return m_isLinked;
}
2016-05-23 21:18:37 +02:00
uint64_t jus::ServiceRemote::getId() {
return m_clientInterface->getId();
2016-05-23 21:18:37 +02:00
}
2016-06-08 21:40:42 +02:00
enum jus::connectionMode jus::ServiceRemote::getMode() {
return m_clientInterface->getMode();
}
2016-06-03 23:45:01 +02:00
jus::FutureBase jus::ServiceRemote::callJson(uint64_t _transactionId,
const ejson::Object& _obj,
const std::vector<ActionAsyncClient>& _async,
jus::FutureData::ObserverFinish _callback) {
2016-06-08 21:40:42 +02:00
return m_clientInterface->callJson(_transactionId, _obj, _async, _callback, m_serviceId);
2016-05-23 21:18:37 +02:00
}
2016-06-08 21:40:42 +02:00
jus::FutureBase jus::ServiceRemote::callBinary(uint64_t _transactionId,
2016-06-09 22:32:24 +02:00
jus::Buffer& _obj,
2016-06-08 21:40:42 +02:00
const std::vector<ActionAsyncClient>& _async,
jus::FutureData::ObserverFinish _callback) {
return m_clientInterface->callBinary(_transactionId, _obj, _async, _callback, m_serviceId);
}