2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Jan Olszak <j.olszak@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
21 * @author Jan Olszak (j.olszak@samsung.com)
22 * @brief Handling client connections
27 #include "ipc/client.hpp"
28 #include "ipc/internals/socket.hpp"
29 #include "ipc/exception.hpp"
31 namespace security_containers {
34 Client::Client(const std::string& socketPath)
35 : mSocketPath(socketPath)
37 LOGD("Creating client");
42 LOGD("Destroying client...");
45 } catch (IPCException& e) {
46 LOGE("Error in Client's destructor: " << e.what());
48 LOGD("Destroyed client");
53 LOGD("Starting client...");
55 // Initialize the connection with the server
56 LOGD("Connecting to " + mSocketPath);
57 auto socketPtr = std::make_shared<Socket>(Socket::connectSocket(mSocketPath));
58 mServiceFD = mProcessor.addPeer(socketPtr);
63 LOGD("Started client");
66 bool Client::isStarted()
68 return mProcessor.isStarted();
73 LOGD("Stopping client...");
78 void Client::setNewPeerCallback(const PeerCallback& newPeerCallback)
80 mProcessor.setNewPeerCallback(newPeerCallback);
83 void Client::setRemovedPeerCallback(const PeerCallback& removedPeerCallback)
85 mProcessor.setRemovedPeerCallback(removedPeerCallback);
88 void Client::removeMethod(const MethodID methodID)
90 LOGD("Removing method id: " << methodID);
91 mProcessor.removeMethod(methodID);
95 } // namespace security_containers