Package com.zeroc.Ice
Interface Connection
public interface Connection
The user-level interface to a connection.
-
Method Summary
Modifier and TypeMethodDescriptionReturn a description of the connection as human readable text, suitable for logging or error messages.void
close
(ConnectionClose mode) Manually close the connection using the specified closure mode.createProxy
(Identity id) Create a special proxy that always uses this connection.void
flushBatchRequests
(CompressBatch compress) Flush any pending batch requests for this connection.flushBatchRequestsAsync
(CompressBatch compress) Flush any pending batch requests for this connection.getACM()
Get the ACM parameters.Get the object adapter that dispatches requests for this connection.Get the endpoint from which the connection was created.getInfo()
Returns the connection information.void
Send a heartbeat message.Send a heartbeat message.void
setACM
(OptionalInt timeout, Optional<ACMClose> close, Optional<ACMHeartbeat> heartbeat) Set the active connection management parameters.void
setAdapter
(ObjectAdapter adapter) Explicitly set an object adapter that dispatches requests that are received over this connection.void
setBufferSize
(int rcvSize, int sndSize) Set the connection buffer receive/send size.void
setCloseCallback
(CloseCallback callback) Set a close callback on the connection.void
setHeartbeatCallback
(HeartbeatCallback callback) Set a heartbeat callback on the connection.void
Throw an exception indicating the reason for connection closure.int
timeout()
Get the timeout for the connection.type()
Return the connection type.
-
Method Details
-
close
Manually close the connection using the specified closure mode.- Parameters:
mode
- Determines how the connection will be closed.- See Also:
-
createProxy
Create a special proxy that always uses this connection. This can be used for callbacks from a server to a client if the server cannot directly establish a connection to the client, for example because of firewalls. In this case, the server would create a proxy using an already established connection from the client.- Parameters:
id
- The identity for which a proxy is to be created.- Returns:
- A proxy that matches the given identity and uses this connection.
- See Also:
-
setAdapter
Explicitly set an object adapter that dispatches requests that are received over this connection. A client can invoke an operation on a server using a proxy, and then set an object adapter for the outgoing connection that is used by the proxy in order to receive callbacks. This is useful if the server cannot establish a connection back to the client, for example because of firewalls.- Parameters:
adapter
- The object adapter that should be used by this connection to dispatch requests. The object adapter must be activated. When the object adapter is deactivated, it is automatically removed from the connection. Attempts to use a deactivated object adapter raiseObjectAdapterDeactivatedException
- See Also:
-
getAdapter
ObjectAdapter getAdapter()Get the object adapter that dispatches requests for this connection.- Returns:
- The object adapter that dispatches requests for the connection, or null if no adapter is set.
- See Also:
-
getEndpoint
Endpoint getEndpoint()Get the endpoint from which the connection was created.- Returns:
- The endpoint from which the connection was created.
-
flushBatchRequests
Flush any pending batch requests for this connection. This means all batch requests invoked on fixed proxies associated with the connection.- Parameters:
compress
- Specifies whether or not the queued batch requests should be compressed before being sent over the wire.
-
flushBatchRequestsAsync
Flush any pending batch requests for this connection. This means all batch requests invoked on fixed proxies associated with the connection.- Parameters:
compress
- Specifies whether or not the queued batch requests should be compressed before being sent over the wire.- Returns:
- A future that will be completed when the invocation completes.
-
setCloseCallback
Set a close callback on the connection. The callback is called by the connection when it's closed. The callback is called from the Ice thread pool associated with the connection. If the callback needs more information about the closure, it can callthrowException()
.- Parameters:
callback
- The close callback object.
-
setHeartbeatCallback
Set a heartbeat callback on the connection. The callback is called by the connection when a heartbeat is received. The callback is called from the Ice thread pool associated with the connection.- Parameters:
callback
- The heartbeat callback object.
-
heartbeat
void heartbeat()Send a heartbeat message. -
heartbeatAsync
CompletableFuture<Void> heartbeatAsync()Send a heartbeat message.- Returns:
- A future that will be completed when the invocation completes.
-
setACM
Set the active connection management parameters.- Parameters:
timeout
- The timeout value in seconds, must be >= 0.close
- The close conditionheartbeat
- The hertbeat condition
-
getACM
ACM getACM()Get the ACM parameters.- Returns:
- The ACM parameters.
-
type
String type()Return the connection type. This corresponds to the endpoint type, i.e., "tcp", "udp", etc.- Returns:
- The type of the connection.
-
timeout
int timeout()Get the timeout for the connection.- Returns:
- The connection's timeout.
-
_toString
String _toString()Return a description of the connection as human readable text, suitable for logging or error messages.- Returns:
- The description of the connection as human readable text.
-
getInfo
ConnectionInfo getInfo()Returns the connection information.- Returns:
- The connection information.
-
setBufferSize
void setBufferSize(int rcvSize, int sndSize) Set the connection buffer receive/send size.- Parameters:
rcvSize
- The connection receive buffer size.sndSize
- The connection send buffer size.
-
throwException
void throwException()Throw an exception indicating the reason for connection closure. For example,CloseConnectionException
is raised if the connection was closed gracefully, whereasConnectionManuallyClosedException
is raised if the connection was manually closed by the application. This operation does nothing if the connection is not yet closed.
-