3#ifndef ICE_CONNECTION_H
4#define ICE_CONNECTION_H
7#include "ConnectionF.h"
9#include "Ice/Identity.h"
11#include "Ice/ProxyFunctions.h"
12#include "ObjectAdapterF.h"
19# pragma clang diagnostic push
20# pragma clang diagnostic ignored "-Wshadow-field-in-constructor"
21#elif defined(__GNUC__)
22# pragma GCC diagnostic push
23# pragma GCC diagnostic ignored "-Wshadow"
42 using HeaderDict = std::map<std::string, std::string, std::less<>>;
56 virtual void abort() noexcept = 0;
67 close(std::function<
void()> response, std::function<
void(std::exception_ptr)> exception) noexcept = 0;
71 [[nodiscard]] std::future<
void>
close();
77 template<typename Prx =
ObjectPrx, std::enable_if_t<std::is_base_of_v<
ObjectPrx, Prx>,
bool> = true>
117 std::function<
void(std::exception_ptr)> exception,
118 std::function<
void(
bool)> sent =
nullptr) = 0;
134 [[nodiscard]] virtual const std::
string&
type() const noexcept = 0;
139 [[nodiscard]] virtual std::
string toString() const = 0;
163 class ICE_API ConnectionInfo
166 virtual ~ConnectionInfo();
169 ConnectionInfo(
const ConnectionInfo&) =
delete;
170 ConnectionInfo& operator=(
const ConnectionInfo&) =
delete;
195 ConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
196 : incoming{incoming},
197 adapterName{std::move(adapterName)},
198 connectionId{std::move(connectionId)}
205 class ICE_API IPConnectionInfo :
public ConnectionInfo
208 IPConnectionInfo(
const IPConnectionInfo&) =
delete;
209 IPConnectionInfo& operator=(
const IPConnectionInfo&) =
delete;
211 ~IPConnectionInfo()
override;
246 class ICE_API TCPConnectionInfo final :
public IPConnectionInfo
249 ~TCPConnectionInfo()
final;
250 TCPConnectionInfo(
const TCPConnectionInfo&) =
delete;
251 TCPConnectionInfo& operator=(
const TCPConnectionInfo&) =
delete;
277 TCPConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
278 :
TCPConnectionInfo{incoming, std::move(adapterName), std::move(connectionId),
"", -1,
"", -1, 0, 0}
285 class ICE_API UDPConnectionInfo final :
public IPConnectionInfo
288 ~UDPConnectionInfo()
final;
289 UDPConnectionInfo(
const UDPConnectionInfo&) =
delete;
290 UDPConnectionInfo& operator=(
const UDPConnectionInfo&) =
delete;
326 UDPConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
327 :
UDPConnectionInfo{incoming, std::move(adapterName), std::move(connectionId),
"", -1,
"", -1,
"", -1, 0, 0}
334 class ICE_API WSConnectionInfo final :
public ConnectionInfo
337 ~WSConnectionInfo()
final;
338 WSConnectionInfo(
const WSConnectionInfo&) =
delete;
339 WSConnectionInfo& operator=(
const WSConnectionInfo&) =
delete;
354 class IAPConnectionInfo final :
public ConnectionInfo
357 ~IAPConnectionInfo()
final;
358 IAPConnectionInfo(
const IAPConnectionInfo&) =
delete;
359 IAPConnectionInfo& operator=(
const IAPConnectionInfo&) =
delete;
401#if defined(__clang__)
402# pragma clang diagnostic pop
403#elif defined(__GNUC__)
404# pragma GCC diagnostic pop
const std::string connectionId
The connection ID.
const bool incoming
Indicates whether the connection is an incoming connection.
const std::string adapterName
The name of the adapter associated with the connection.
const ConnectionInfoPtr underlying
The information of the underlying transport or nullptr if there's no underlying transport.
Base class for all connection info classes.
virtual std::function< void()> flushBatchRequestsAsync(CompressBatch compress, std::function< void(std::exception_ptr)> exception, std::function< void(bool)> sent=nullptr)=0
Flushes any pending batch requests for this connection.
virtual ObjectAdapterPtr getAdapter() const noexcept=0
Gets the object adapter associated with this connection.
virtual void setAdapter(const ObjectAdapterPtr &adapter)=0
Associates an object adapter with this connection.
virtual void close(std::function< void()> response, std::function< void(std::exception_ptr)> exception) noexcept=0
Starts a graceful closure of this connection once all outstanding invocations have completed.
virtual ConnectionInfoPtr getInfo() const =0
Returns the connection information.
virtual void setBufferSize(int rcvSize, int sndSize)=0
Sets the size of the receive and send buffers.
virtual std::string toString() const =0
Returns a description of the connection as human readable text, suitable for logging or error message...
virtual void setCloseCallback(CloseCallback callback)=0
Sets a close callback on the connection.
Prx createProxy(Identity id) const
Creates a special proxy (a "fixed proxy") that always uses this connection.
virtual void abort() noexcept=0
Aborts this connection.
virtual EndpointPtr getEndpoint() const noexcept=0
Gets the endpoint from which the connection was created.
void flushBatchRequests(CompressBatch compress)
Flushes any pending batch requests for this connection.
virtual const std::string & type() const noexcept=0
Returns the connection type.
virtual void throwException() const =0
Throws an exception that provides the reason for the closure of this connection.
Represents a connection that uses the Ice protocol.
const std::string manufacturer
The accessory manufacturer.
const std::string firmwareRevision
The accessory firmware revision.
const std::string protocol
The protocol used by the accessory.
const std::string modelNumber
The accessory model number.
const std::string name
The accessory name.
const std::string hardwareRevision
The accessory hardware revision.
const int localPort
The local port.
const std::string localAddress
The local address.
const int remotePort
The remote port.
const std::string remoteAddress
The remote address.
The base class for all Ice proxies.
const int rcvSize
The size of the receive buffer.
const int sndSize
The size of the send buffer.
Provides access to the connection details of a TCP connection.
const int rcvSize
The size of the receive buffer.
const int mcastPort
The multicast port.
const int sndSize
The size of the send buffer.
const std::string mcastAddress
The multicast address.
Provides access to the connection details of a UDP connection.
const HeaderDict headers
The headers from the HTTP upgrade request.
std::shared_ptr< ConnectionInfo > ConnectionInfoPtr
A shared pointer to a ConnectionInfo.
std::shared_ptr< ObjectAdapter > ObjectAdapterPtr
A shared pointer to an ObjectAdapter.
Prx uncheckedCast(const ObjectPrx &proxy)
Creates a new proxy from an existing proxy.
std::shared_ptr< Endpoint > EndpointPtr
A shared pointer to an Endpoint.
std::map< std::string, std::string, std::less<> > HeaderDict
Represents a collection of HTTP headers.
std::function< void(const ConnectionPtr &con)> CloseCallback
The callback function given to Connection::setCloseCallback.
std::shared_ptr< Connection > ConnectionPtr
A shared pointer to a Connection.
CompressBatch
Represents batch compression options when flushing queued batch requests.
@ BasedOnProxy
Compress the batch requests if at least one request was made on a compressed proxy.
@ Yes
Compress the batch requests.
@ No
Don't compress the batch requests.
Represents the identity of an Ice object.