public interface Connector
start() method has been invoked,
applications can use the send(RawData) method to send messages
(wrapped in a RawData object) to a client via the network. Processing of
messages received from clients is delegated to the handler registered via the
setRawDataReceiver(RawDataChannel) method.
Implementations of the send(RawData) method should be non-blocking
to allow the server application to continue working on other tasks. This could
be achieved by buffering outbound messages in a queue and off-loading the sending
of messages via the network to a separate Thread.| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Stops the connector and cleans up any leftovers.
|
InetSocketAddress |
getAddress()
Gets the address of the socket this connector is bound to.
|
String |
getProtocol()
Returns the protocol of the connector.
|
void |
send(RawData msg)
Sends a raw message to a client via the network.
|
void |
setEndpointContextMatcher(EndpointContextMatcher matcher)
Set endpoint context matcher to be used for sending messages.
|
void |
setRawDataReceiver(RawDataChannel messageHandler)
Sets the handler for incoming messages.
|
void |
start()
Starts the connector.
|
void |
stop()
Stops the connector.
|
void start()
throws IOException
IOException - Signals that an I/O exception has occurred.void stop()
start() method.void destroy()
void send(RawData msg)
This should be a non-blocking operation.
The MessageCallback registered on the message will be
notified about the different stages that the message is going
through as part of being sent.
msg - the message to be sentNullPointerException - if the message is null.IllegalArgumentException - if the message cannot be sent due to formal
constraints, e.g. because the message's payload
is too large.IllegalStateException - if the connector has not been started.void setRawDataReceiver(RawDataChannel messageHandler)
RawDataChannel.receiveData(RawData) method
will be called whenever a new message from a client has been received
via the network.messageHandler - the message handlerIllegalStateException - if the connector is running.void setEndpointContextMatcher(EndpointContextMatcher matcher)
matcher - endpoint context matcherEndpointContextMatcher.isToBeSent(EndpointContext, EndpointContext)InetSocketAddress getAddress()
Note that the IP address returned might be a wildcard address, indicating that this connector is listening on all network interface's IP addresses.
The connector may have been configured to bind to an ephemeral port. In such cases the concrete port that the connector is bound to will only be known after it has been started.
If the connector is not running, the semantics of the address returned is undefined. It may be a default (wildcard) address or the address the connector has been configured to bind to.
String getProtocol()
"UDP", "DTLS", "TCP", or "TLS"Copyright © 2019 Eclipse Foundation. All rights reserved.