diff options
author | Mark Spruiell <mes@zeroc.com> | 2015-11-06 11:24:22 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2015-11-06 11:24:22 -0800 |
commit | 61f9f44b8eda9c9cdb9139436d4ad87e6e7d5839 (patch) | |
tree | 286025a254ce57d02068551f11cf69b89fa66a72 /cpp/src/IceBT/TransceiverI.cpp | |
parent | A few changes to support move of Freeze (diff) | |
download | ice-61f9f44b8eda9c9cdb9139436d4ad87e6e7d5839.tar.bz2 ice-61f9f44b8eda9c9cdb9139436d4ad87e6e7d5839.tar.xz ice-61f9f44b8eda9c9cdb9139436d4ad87e6e7d5839.zip |
initial commit of C++ Bluetooth transport
Diffstat (limited to 'cpp/src/IceBT/TransceiverI.cpp')
-rw-r--r-- | cpp/src/IceBT/TransceiverI.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/cpp/src/IceBT/TransceiverI.cpp b/cpp/src/IceBT/TransceiverI.cpp new file mode 100644 index 00000000000..8ce1241870a --- /dev/null +++ b/cpp/src/IceBT/TransceiverI.cpp @@ -0,0 +1,117 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceBT/TransceiverI.h> +#include <IceBT/ConnectionInfo.h> +#include <IceBT/Engine.h> +#include <IceBT/Instance.h> +#include <IceBT/Util.h> + +#include <Ice/Connection.h> +#include <Ice/LocalException.h> + +#include <IceUtil/DisableWarnings.h> + +using namespace std; +using namespace Ice; +using namespace IceBT; + +IceInternal::NativeInfoPtr +IceBT::TransceiverI::getNativeInfo() +{ + return _stream; +} + +IceInternal::SocketOperation +IceBT::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::Buffer& writeBuffer) +{ + return IceInternal::SocketOperationNone; // Already connected. +} + +IceInternal::SocketOperation +IceBT::TransceiverI::closing(bool initiator, const Ice::LocalException&) +{ + // If we are initiating the connection closure, wait for the peer + // to close the TCP/IP connection. Otherwise, close immediately. + return initiator ? IceInternal::SocketOperationRead : IceInternal::SocketOperationNone; +} + +void +IceBT::TransceiverI::close() +{ + if(_connection) + { + _connection->close(); + } + _stream->close(); +} + +IceInternal::SocketOperation +IceBT::TransceiverI::write(IceInternal::Buffer& buf) +{ + return _stream->write(buf); +} + +IceInternal::SocketOperation +IceBT::TransceiverI::read(IceInternal::Buffer& buf) +{ + return _stream->read(buf); +} + +string +IceBT::TransceiverI::protocol() const +{ + return _instance->protocol(); +} + +string +IceBT::TransceiverI::toString() const +{ + return _stream->toString(); +} + +string +IceBT::TransceiverI::toDetailedString() const +{ + return toString(); +} + +Ice::ConnectionInfoPtr +IceBT::TransceiverI::getInfo() const +{ + IceBT::ConnectionInfoPtr info = new IceBT::ConnectionInfo(); + fdToAddressAndChannel(_stream->fd(), info->localAddress, info->localChannel, info->remoteAddress, + info->remoteChannel); + info->uuid = _uuid; + return info; +} + +void +IceBT::TransceiverI::checkSendSize(const IceInternal::Buffer&) +{ +} + +void +IceBT::TransceiverI::setBufferSize(int rcvSize, int sndSize) +{ + _stream->setBufferSize(rcvSize, sndSize); +} + +IceBT::TransceiverI::TransceiverI(const InstancePtr& instance, const StreamSocketPtr& stream, const ConnectionPtr& conn, + const string& uuid) : + _instance(instance), + _stream(stream), + _connection(conn), + _uuid(uuid) +{ +} + +IceBT::TransceiverI::~TransceiverI() +{ +} |