Files
nearby/cpp/core/internal/bluetooth_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.8 KiB
C++

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