mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: I2cf5bf225b76f4c1541954651f3a7544a14e0cec
56 lines
1.8 KiB
C++
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
|