The Diffusion Publisher API is deprecated and will be removed in a future release.
@Deprecated public class DefaultClientListener extends Object implements ClientListener
ClientListener
which may be
extended to implement only those event notifications that you wish to
process.
For simplest use this can be used to specify an anonymous class listener as follows:
Publishers.addEventListener(
new DefaultClientListener() {
public void clientQueueThresholdReached(
Client client,boolean upper,int threshold) {
if (upper) {
TopicMessage alertMessage = createDeltaMessage("Alerts");
alertMessage.put("Client queue threshold exceeded");
alertMessage.setExpedited(true);
publishSingleMessage(alertMessage,client);
}
}
},
ClientListener.QUEUE_THRESHOLD_REACHED);
As the above example shows the advantage of using anonymous classes is that it is possible to directly access the methods or instance variables of the Publisher itself in the same way as if the code was within the Publisher class itself.
CLOSED, CONNECTED, FETCH_INVALID, NEW_CREDENTIALS, PING_RESPONSE, QUEUE_THRESHOLD_REACHED, RESOLVED, SUBSCRIPTION_INVALID
Constructor and Description |
---|
DefaultClientListener()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
clientClosed(Client client)
Deprecated.
This is called when a client connection is closed.
|
void |
clientConnected(Client client)
Deprecated.
This is called when a new client is connected.
|
void |
clientCredentials(Client client,
Credentials credentials)
Deprecated.
Notifies that a client has changed it's principal.
|
void |
clientFetchInvalid(Client client,
String topicName,
List<String> headers)
Deprecated.
This is called when a client attempts to fetch a topic that does not
exist.
|
void |
clientPingResponse(ClientConnection client,
ClientPingMessage response)
Deprecated.
This is called when a response to a 'ping' sent to a client is received.
|
void |
clientQueueThresholdReached(Client client,
boolean upper,
int threshold)
Deprecated.
Notifies an outbound message queue threshold has been reached.
|
void |
clientResolved(Client client)
Deprecated.
This is called when a client's Internet address details have been
resolved.
|
void |
clientSubscriptionInvalid(Client client,
String topicName)
Deprecated.
This is called when a client attempts to subscribe to a topic that does
not exist.
|
public void clientConnected(Client client)
ClientListener
This is a synchronous notification and so this method should return as promptly as possible to avoid blocking an inbound thread. Any significant processing should be delegated to another thread.
clientConnected
in interface ClientListener
client
- the client that has connected.public void clientSubscriptionInvalid(Client client, String topicName)
ClientListener
This only occurs when a topic name is specified that does not exist and not if a topic selector is specified which matches no current topics.
clientSubscriptionInvalid
in interface ClientListener
client
- the client.topicName
- the name of the topic that the client has attempted to
subscribe to.public void clientFetchInvalid(Client client, String topicName, List<String> headers)
ClientListener
This only occurs when a topic name is specified that does not exist and not if a topic selector is specified which matches no current topics.
This notification only occurs when using the deprecated
Topics.fetch(com.pushtechnology.diffusion.client.topics.TopicSelector, com.pushtechnology.diffusion.client.features.Topics.FetchStream)
feature. The newer Topics.fetchRequest()
feature does not support notifications.
clientFetchInvalid
in interface ClientListener
client
- the client.topicName
- the name of the topic that the client has attempted to
fetch.headers
- this parameter is redundant - an empty list will always be
passedpublic void clientResolved(Client client)
ClientListener
The client is resolved using the WhoIs service and then notified.
Client.getWhoIsDetails()
can be used to obtain the fully resolved
details of the client.
clientResolved
in interface ClientListener
client
- the client that has been resolved.public void clientQueueThresholdReached(Client client, boolean upper, int threshold)
ClientListener
This will only be called if message queue thresholds have been declared.
See Client.setQueueNotificationThresholds(int, int)
for details
of the meanings of the thresholds.
clientQueueThresholdReached
in interface ClientListener
client
- the client connection.upper
- true to notify upper threshold reached, false to notify
lower threshold reached.threshold
- the threshold value.public void clientPingResponse(ClientConnection client, ClientPingMessage response)
ClientPingResponseListener
clientPingResponse
in interface ClientPingResponseListener
client
- the connection from which the ping response is being
received.response
- the ping response message.public void clientCredentials(Client client, Credentials credentials)
ClientListener
The client may supply a principal and credentials on connection and may change principal after connection, any number of times. This notification is caused whenever a client changes it's principal.
This will be notified only after the new principal's credentials have been validated.
This is a synchronous notification and so this method should return as promptly as possible to avoid blocking an inbound thread. Any significant processing should be delegated to another thread.
clientCredentials
in interface ClientListener
client
- the client connection.credentials
- a credentials object indicating the new principalpublic void clientClosed(Client client)
ClientListener
clientClosed
in interface ClientListener
client
- the client that closed.Copyright © 2020 Push Technology Ltd. All Rights Reserved.