Files
nearby/cpp/core/internal/ble_endpoint_channel.cc
T
Alexey Polyudov 204f76077d nearby: snapshot as of cl/296436629
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: I2cf5bf225b76f4c1541954651f3a7544a14e0cec
2020-04-04 12:52:31 -07:00

56 lines
1.6 KiB
C++

#include "core/internal/ble_endpoint_channel.h"
#include <string>
namespace location {
namespace nearby {
namespace connections {
template <typename Platform>
Ptr<BLEEndpointChannel<Platform> >
BLEEndpointChannel<Platform>::createOutgoing(
Ptr<MediumManager<Platform> > medium_manager, const string& channel_name,
Ptr<BLESocket> ble_socket) {
return MakePtr(
new BLEEndpointChannel<Platform>(channel_name, ble_socket));
}
template <typename Platform>
Ptr<BLEEndpointChannel<Platform> >
BLEEndpointChannel<Platform>::createIncoming(
Ptr<MediumManager<Platform> > medium_manager, const string& channel_name,
Ptr<BLESocket> ble_socket) {
return MakePtr(
new BLEEndpointChannel<Platform>(channel_name, ble_socket));
}
template <typename Platform>
BLEEndpointChannel<Platform>::BLEEndpointChannel(
const string& channel_name, Ptr<BLESocket> ble_socket)
: BaseEndpointChannel<Platform>(channel_name,
ble_socket->getInputStream(),
ble_socket->getOutputStream()),
ble_socket_(ble_socket) {}
template <typename Platform>
BLEEndpointChannel<Platform>::~BLEEndpointChannel() {}
template <typename Platform>
proto::connections::Medium BLEEndpointChannel<Platform>::getMedium() {
return proto::connections::Medium::BLE;
}
template <typename Platform>
void BLEEndpointChannel<Platform>::closeImpl() {
Exception::Value exception = ble_socket_->close();
if (exception != Exception::NONE) {
if (exception == Exception::IO) {
// TODO(ahlee): Add logging.
}
}
}
} // namespace connections
} // namespace nearby
} // namespace location