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;
68 close(std::function<
void()> response, std::function<
void(std::exception_ptr)> exception) noexcept = 0;
72 [[nodiscard]] std::future<
void>
close();
79 template<typename Prx =
ObjectPrx, std::enable_if_t<std::is_base_of_v<
ObjectPrx, Prx>,
bool> = true>
131 std::function<
void(std::exception_ptr)> exception,
132 std::function<
void(
bool)> sent =
nullptr) = 0;
152 [[nodiscard]] virtual const std::
string&
type() const noexcept = 0;
157 [[nodiscard]] virtual std::
string toString() const = 0;
181 class ICE_API ConnectionInfo
184 virtual ~ConnectionInfo();
187 ConnectionInfo(
const ConnectionInfo&) =
delete;
188 ConnectionInfo& operator=(
const ConnectionInfo&) =
delete;
213 ConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
214 : incoming{incoming},
215 adapterName{std::move(adapterName)},
216 connectionId{std::move(connectionId)}
223 class ICE_API IPConnectionInfo :
public ConnectionInfo
226 IPConnectionInfo(
const IPConnectionInfo&) =
delete;
227 IPConnectionInfo& operator=(
const IPConnectionInfo&) =
delete;
229 ~IPConnectionInfo()
override;
264 class ICE_API TCPConnectionInfo final :
public IPConnectionInfo
267 ~TCPConnectionInfo()
final;
268 TCPConnectionInfo(
const TCPConnectionInfo&) =
delete;
269 TCPConnectionInfo& operator=(
const TCPConnectionInfo&) =
delete;
295 TCPConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
296 :
TCPConnectionInfo{incoming, std::move(adapterName), std::move(connectionId),
"", -1,
"", -1, 0, 0}
303 class ICE_API UDPConnectionInfo final :
public IPConnectionInfo
306 ~UDPConnectionInfo()
final;
307 UDPConnectionInfo(
const UDPConnectionInfo&) =
delete;
308 UDPConnectionInfo& operator=(
const UDPConnectionInfo&) =
delete;
344 UDPConnectionInfo(
bool incoming, std::string adapterName, std::string connectionId)
345 :
UDPConnectionInfo{incoming, std::move(adapterName), std::move(connectionId),
"", -1,
"", -1,
"", -1, 0, 0}
352 class ICE_API WSConnectionInfo final :
public ConnectionInfo
355 ~WSConnectionInfo()
final;
356 WSConnectionInfo(
const WSConnectionInfo&) =
delete;
357 WSConnectionInfo& operator=(
const WSConnectionInfo&) =
delete;
373 class IAPConnectionInfo final :
public ConnectionInfo
376 ~IAPConnectionInfo()
final;
377 IAPConnectionInfo(
const IAPConnectionInfo&) =
delete;
378 IAPConnectionInfo& operator=(
const IAPConnectionInfo&) =
delete;
420#if defined(__clang__)
421# pragma clang diagnostic pop
422#elif defined(__GNUC__)
423# 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 the 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 HTTP headers from the WebSocket upgrade handshake: the request headers for an incoming connection...
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 for 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.