2 * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
21 const std::string ODE_MANAGER_ADDRESS = "/tmp/.ode.sock";
26 ClientContext::ClientContext() noexcept
30 ClientContext::~ClientContext() noexcept
35 int ClientContext::connect(const std::string& address) noexcept
38 client.reset(new rmi::Client(address));
40 } catch (runtime::Exception& e) {
47 int ClientContext::connect() noexcept
49 return connect(ODE_MANAGER_ADDRESS);
52 void ClientContext::disconnect() noexcept
57 int ClientContext::subscribeSignal(const std::string& name,
58 const SignalListener& listener,
61 auto listenerDispatcher = [listener, data](std::string name) {
66 int ret = client->subscribe<std::string>
67 (SUBSCRIBER_REGISTER, name, listenerDispatcher);
69 return ode::error::Unknown;
71 } catch (runtime::Exception& e) {
72 std::cout << e.what() << std::endl;
73 return ode::error::Unknown;
77 void ClientContext::unsubscribeSignal(int subscriberId)
79 client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);