public abstract class AbstractDiffusionClient extends Object implements DiffusionConnectionListener, DiffusionTopicStatusListener
Modifier and Type | Field and Description |
---|---|
protected ConnectionDetails |
theConnectionDetails |
Constructor and Description |
---|
AbstractDiffusionClient() |
Modifier and Type | Method and Description |
---|---|
void |
addTopicListener(TopicListener topicListener)
addTopicListener
|
void |
close()
close, close the connection to Diffusion, this will also remove any topic
listeners
|
abstract void |
connect()
connect
|
void |
connected(ServerDetails serverDetails)
connected
|
void |
connectionAborted(ServerDetails serverDetails)
connectionAborted
|
PagedTopicHandler |
createPagedTopicHandler(Message message,
PagedTopicListener listener)
Creates a handler object for a 'paged' Topic.
|
ServiceTopicHandler |
createServiceTopicHandler(Message message,
ServiceTopicListener listener)
Creates a handler object for a 'Service' Topic.
|
TopicNotifyTopicHandler |
createTopicNotifyTopicHandler(Message message,
TopicNotifyTopicListener listener)
Creates a handler object for a 'Topic Notify' Topic.
|
void |
disconnected(ServerDetails serverDetails)
disconnected
|
void |
errorConnecting(Exception e)
errorConnecting
|
void |
fetch(String topicName)
Issue a fetch request to the Diffusion server.
|
void |
fetch(String topicName,
String[] headers)
Issue a fetch request to the Diffusion server.
|
String |
getClientID()
getClientID
|
ConnectionDetails |
getConnectionDetails() |
DiffusionConnectionListener |
getConnectionListener()
getConnectionListener
|
long |
getLastInteraction()
Returns the time (milliseconds since the epoch) of the
last interaction (send or recieve) with the server.
|
static Hashtable |
getProperties()
Fetch the store for global Diffusion client settings
|
DiffusionTopicStatusListener |
getTopicStatusListener() |
abstract com.pushtechnology.mobile.internal.DiffusionTransport |
getTransport()
getTransport
|
void |
insertTopicListener(TopicListener topicListener)
Add the topic listener to the front of the list of topic listeners
|
boolean |
isAutoAck()
isAutoAck
|
boolean |
isConnected()
isConnected
|
boolean |
isDebug()
Fetch the value of the debug toggle.
|
boolean |
isReconnected()
isReconnected
|
abstract void |
logException(Throwable thr)
Log the exception, in a manner consistent with the platform.
|
void |
onConnectionDetailsAcquired(ServerDetails serverDetails)
Called prior to attempted connection to the given ServerDetails object
|
void |
onConnectionSequenceExhausted()
Called when the set of ServerDetail objects has been exhausted
|
void |
onMessage(Message message)
handleDiffusionMessage
|
void |
onMessageNotAcknowledged(TopicMessage message)
onMessageNotAcknowledged
|
void |
onPingMessage(PingMessage message)
onPingMessage
|
void |
onServerRejectedCredentials(ServerDetails serverDetails)
onServerRejectedCredentials
|
void |
ping()
ping, send a ping request to the Diffusion Server, this will respond on
the @see DiffusionConnectionListsener.onPingMessage
|
abstract void |
reconnect()
Reconnect, and reestablish state
|
void |
removeTopicListener(TopicListener topicListener)
removeTopicListener
|
void |
send(String topicName,
String message)
send Send a message to Diffusion on a given topic
|
void |
sendCredentials(DiffusionClientCredentials credentials)
Send credentials to the sever
|
void |
sendMessage(TopicMessage topicMessage,
com.pushtechnology.mobile.enums.MessageType messageType)
Send a message to the server
|
void |
sendTopicMessage(TopicMessage topicMessage)
sendTopicMessage Send a topic message to Diffusion
|
void |
setAutoAck(boolean autoAck)
setAutoAck
|
void |
setConnectionDetails(ConnectionDetails theConnectionDetails) |
void |
setConnectionListener(DiffusionConnectionListener connectionListener)
setConnectionListener Set the connection listener for this connection
|
void |
setDebug(boolean debug)
Set the value of the debug toggle
|
void |
setIsConnectedToDiffusion(boolean value) |
void |
setIsReconnectedToDiffusion(boolean value) |
void |
setTopicStatusListener(DiffusionTopicStatusListener theDiffusionTopicStatusListener) |
void |
subscribe(String topic)
subscribe Subscribe the client to a TopicSet of topics, or an individual
topic
|
void |
topicDeleted(String rawTopicName)
Notification delivery slot.
|
void |
unsubscribe(String topicName)
unsubscribe
|
protected ConnectionDetails theConnectionDetails
public void sendCredentials(DiffusionClientCredentials credentials) throws APIException
credentials
- APIException
public DiffusionTopicStatusListener getTopicStatusListener()
public void setTopicStatusListener(DiffusionTopicStatusListener theDiffusionTopicStatusListener)
public boolean isConnected()
public boolean isReconnected()
public void close() throws APIException
APIException
- thrown if the client is not currently connected.public String getClientID() throws APIException
APIException
- thrown if the client is not currently connected.public void ping() throws APIException
APIException
- thrown if the client is not currently connected.public void addTopicListener(TopicListener topicListener)
topicListener
- Add a TopicListener to the current list of listenerspublic void insertTopicListener(TopicListener topicListener)
Required by Service/Command listeners
topicListener
- public void removeTopicListener(TopicListener topicListener)
topicListener
- topicListener to remove from the current list of
listenerspublic void send(String topicName, String message) throws APIException
topicName
- message
- APIException
- thrown if the client is not currently connected.public void sendTopicMessage(TopicMessage topicMessage) throws APIException
topicMessage
- APIException
- thrown if the client is not currently connected.public void sendMessage(TopicMessage topicMessage, com.pushtechnology.mobile.enums.MessageType messageType) throws APIException
Payload is held in the TopicMessage, but message-type is explicitly given
topicMessage
- messageType
- Value from DiffusionConstants
APIException
public void fetch(String topicName) throws APIException
topicName
- Name of the Diffusion topic to fetch.APIException
- thrown if the client is not currently connected.public void fetch(String topicName, String[] headers) throws APIException
topicName
- APIException
- thrown if the client is not currently connected.public void subscribe(String topic) throws APIException
topic
- APIException
- thrown if the client is not currently connected.public void unsubscribe(String topicName) throws APIException
Unsubscribe the client from a TopicSet of topics, or an individual topic
topicName
- APIException
- thrown if the client is not currently connected.public void setConnectionListener(DiffusionConnectionListener connectionListener)
connectionListener
- public DiffusionConnectionListener getConnectionListener()
public void onMessage(Message message)
onMessage
in interface DiffusionConnectionListener
message
- public abstract void logException(Throwable thr)
Should only log if setDebug( true )
has been called.
thr
- Throwable for loggingpublic void connected(ServerDetails serverDetails)
DiffusionConnectionListener
connected
in interface DiffusionConnectionListener
public void disconnected(ServerDetails serverDetails)
DiffusionConnectionListener
disconnected
in interface DiffusionConnectionListener
public void setIsConnectedToDiffusion(boolean value)
public void setIsReconnectedToDiffusion(boolean value)
public void errorConnecting(Exception e)
DiffusionConnectionListener
errorConnecting
in interface DiffusionConnectionListener
public void connectionAborted(ServerDetails serverDetails)
DiffusionConnectionListener
connectionAborted
in interface DiffusionConnectionListener
public void onPingMessage(PingMessage message)
DiffusionConnectionListener
onPingMessage
in interface DiffusionConnectionListener
public void onServerRejectedCredentials(ServerDetails serverDetails)
DiffusionConnectionListener
onServerRejectedCredentials
in interface DiffusionConnectionListener
public void onMessageNotAcknowledged(TopicMessage message)
DiffusionConnectionListener
onMessageNotAcknowledged
in interface DiffusionConnectionListener
public void onConnectionSequenceExhausted()
DiffusionConnectionListener
onConnectionSequenceExhausted
in interface DiffusionConnectionListener
public void onConnectionDetailsAcquired(ServerDetails serverDetails)
DiffusionConnectionListener
onConnectionDetailsAcquired
in interface DiffusionConnectionListener
serverDetails
- ServerDetails object that has been selected for attempted connectionpublic boolean isAutoAck()
public void setAutoAck(boolean autoAck)
autoAck
- false means that the implementation will need to provide
the Acknowledgement back to the Diffusion Serverpublic void topicDeleted(String rawTopicName)
topicDeleted
in interface DiffusionTopicStatusListener
rawTopicName
- Name of the deleted topicpublic abstract com.pushtechnology.mobile.internal.DiffusionTransport getTransport()
public ConnectionDetails getConnectionDetails()
public void setConnectionDetails(ConnectionDetails theConnectionDetails)
public long getLastInteraction()
public abstract void reconnect() throws APIException
APIException
- thrown if the client is not currently connected.public abstract void connect()
public ServiceTopicHandler createServiceTopicHandler(Message message, ServiceTopicListener listener) throws APIException
See ServiceTopicData for details of Service Topics.
This would be called in response to receiving a
load
message from a Service Topic as
a result of subscribing to it. Note that no other messages would be
received from a Service Topic other than via the specified
ServiceTopicListener
.
message
- the load message received from the Topic.listener
- an object that is to receive all Service replies and notifications.APIException
- if unable to create the handler.public PagedTopicHandler createPagedTopicHandler(Message message, PagedTopicListener listener) throws APIException
See PagedTopicData for details of paged Topics.
This would be called in response to receiving a
load
message from a paged Topic as a
result of subscribing to it. Note that no other messages would be
received from a paged Topic until the returned handler is used to
open
the Topic.
message
- the load message received from the Topic.listener
- an object that is to receive all notifications from the
Topic.APIException
- if unable to create the handler.public TopicNotifyTopicHandler createTopicNotifyTopicHandler(Message message, TopicNotifyTopicListener listener) throws APIException
See TopicNotifyTopicData for details of Topic Notify Topics.
This would be called in response to receiving a
load
message from a Topic Notify
Topic as a result of subscribing to it. Note that no other messages would
be received from a Topic Notify Topic until the returned handler is used
to select notifications required.
message
- the load message received from the Topic.listener
- an object that is to receive all notifications from the
Topic.APIException
- if unable to create the handler.public boolean isDebug()
Defaults to false.
public void setDebug(boolean debug)
If this is true, then exceptions caught by the transport when handling messages are logged using Log.e( debugTag, ... )
debug
- new value of the debug togglepublic static Hashtable getProperties()
Fetch the store for global Diffusion client settings
Global client properties | ||
---|---|---|
Property name | Descriptiom | Default |
client.recycleBuffer | This property governs whether the Diffusion client reuses or reallocates the
message input buffer prior to consuming and parsing a Diffusion message from the server connection. If true the input buffer is recycled, potentially saving time and preventing memory fragmentation. |
false |
client.bufferSize | The default size of the input buffer when it is (re)allocated. Buffers are grown to contain their messages. | 32 |
client.recycleMessageObject | The argument to DiffusionConnectionListener.onMessage() can be recycled rather than reused. This optimisation can preserve memory and guard against memory protection. Setting this property to true instructs the Diffusion client to recycle this object. | false |
Copyright © 2016 Push Technology Ltd. All Rights Reserved.