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;
137 [[nodiscard]] virtual const std::
string&
type() const noexcept = 0;
142 [[nodiscard]] virtual std::
string toString() const = 0;
166 class ICE_API ConnectionInfo
169 virtual ~ConnectionInfo();
172 ConnectionInfo(
const ConnectionInfo&) =
delete;
173 ConnectionInfo& operator=(
const ConnectionInfo&) =
delete;
198 ConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
199 : incoming{incoming},
200 adapterName{std::move(adapterName)},
201 connectionId{std::move(connectionId)}
208 class ICE_API IPConnectionInfo :
public ConnectionInfo
211 IPConnectionInfo(
const IPConnectionInfo&) =
delete;
212 IPConnectionInfo& operator=(
const IPConnectionInfo&) =
delete;
214 ~IPConnectionInfo()
override;
249 class ICE_API TCPConnectionInfo final :
public IPConnectionInfo
252 ~TCPConnectionInfo()
final;
253 TCPConnectionInfo(
const TCPConnectionInfo&) =
delete;
254 TCPConnectionInfo& operator=(
const TCPConnectionInfo&) =
delete;
280 TCPConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
281 :
TCPConnectionInfo{incoming, std::move(adapterName), std::move(connectionId),
"", -1,
"", -1, 0, 0}
288 class ICE_API UDPConnectionInfo final :
public IPConnectionInfo
291 ~UDPConnectionInfo()
final;
292 UDPConnectionInfo(
const UDPConnectionInfo&) =
delete;
293 UDPConnectionInfo& operator=(
const UDPConnectionInfo&) =
delete;
329 UDPConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
330 :
UDPConnectionInfo{incoming, std::move(adapterName), std::move(connectionId),
"", -1,
"", -1,
"", -1, 0, 0}
337 class ICE_API WSConnectionInfo final :
public ConnectionInfo
340 ~WSConnectionInfo()
final;
341 WSConnectionInfo(
const WSConnectionInfo&) =
delete;
342 WSConnectionInfo& operator=(
const WSConnectionInfo&) =
delete;
357 class IAPConnectionInfo final :
public ConnectionInfo
360 ~IAPConnectionInfo()
final;
361 IAPConnectionInfo(
const IAPConnectionInfo&) =
delete;
362 IAPConnectionInfo& operator=(
const IAPConnectionInfo&) =
delete;
404#if defined(__clang__)
405# pragma clang diagnostic pop
406#elif defined(__GNUC__)
407# 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 disableInactivityCheck() noexcept=0
Disables the inactivity check on 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.