Table of Contents
Just a second...

Android Classic API examples

Examples that use the Android™ Classic API.

DiffusionClient

The following code shows an example of connection:
    // Get a new DiffusionClient
    theClient = new DiffusionClient();
    
    //Set the connection details
    ServerDetails serverDetails = new ServerDetails(new URL("dpt://diffusion.example.com:80"));
    ConnectionDetails connectionDetails = new ConnectionDetails(serverDetails);
    theClient.setConnectionDetails(connectionDetails);
    
    // Make this listen to the DiffusionClient events    
    theClient.setConnectionListener(this);
        
    // Connect 
    theClient.connect();

DiffusionConnectionListener

The DiffusionConnectionListener interface consists of the following methods (for further information refer to the API documentation)

    /**
     * connected, called upon connection
     */
    void connected();
 
    /**
     * errorConnecting, called if there is an error connecting
     * 
     * @param e
     */
    void errorConnecting(Exception e);
 
    /**
     * disconnected, called when the connection list lost
     */
    void disconnected();
 
    /**
     * connectionAborted, called when DiffusionServer has rejected the connection
     */
    void connectionAborted();
 
    /**
     * onMessage, called when a message has been received from Diffusion
     * 
     * @param message
     */
    void onMessage(Message message);
 
    /**
     * onPingMessage, called when a ping response is received
     * 
     * @param message
     */
    void onPingMessage(PingMessage message);
        
    /**
     * onMessageNotAcknowledged, called when an ack message has not been acknowledged by Diffusion
     * 
     * @param message
     */
    public void onMessageNotAcknowledged(TopicMessage message);        
    
    /**
     * onConnectionSequenceExhausted, called when the complete list of ServerDetails have been exhausted.
     */
    public void onConnectionSequenceExhausted();
	
    /**
     * onConnectionDetailsAcquired, called each time a ServerDetails object is selected for connection.
     * 
     * @param serverDetails
     */
    public void onConnectionDetailsAcquired(ServerDetails serverDetails);
		
    /**
     * onServerRejectedCredentials, called when Diffusion reject the credentials.
     */	
    public void onServerRejectedCredentials();

Change the URL from that provided in the example to the URL of the Diffusion™ server.