com.unclouded.android
Class Unclouded

java.lang.Object
  extended by com.unclouded.android.Unclouded

public class Unclouded
extends Object

Represents the Unclouded event loop. This is the central entity that manages all communication and lets you perform fundamental Unclouded tasks, such as establishing a connection to the Network, publishing a service and discovering services of a particular TypeTag.

The Unclouded event loop adopts event-driven communication and consists of an event queue that stores (incoming) events. These events are sequentially processed, one at a time. Interactions between event loops are processed asynchronously.

To get the Unclouded instance representing the local Unclouded event loop, call the static getInstance() method.

Developer Guide
For more information about using Unclouded, read the Unclouded developer guide.


Method Summary
 ServicePublication broadcast(TypeTag typeTag, Double d)
          Broadcast a service holding a Double across the network.
 ServicePublication broadcast(TypeTag typeTag, Integer i)
          Broadcast a service holding a Integer across the network.
 ServicePublication broadcast(TypeTag typeTag, Serializable serializable)
          Broadcast a service holding a Serializable object across the network.
 ServicePublication broadcast(TypeTag typeTag, String s)
          Broadcast a service holding a String across the network.
 ServicePublication broadcast(TypeTag typeTag, UObject obj)
          Broadcast a service referencing an UObject across the network.
static Unclouded getInstance()
          Get a handle to the Unclouded instance.
 void goOffline()
          Disconnect from the network.
 Network goOnline()
          Connect to the network and obtain a network address.
 void reset()
          Disconnect from the network and reset the event loop.
 ServiceSubscription when(TypeTag typeTag, ServiceListener<? extends Object> listener)
          Listen for a single service of a particular TypeTag in the network.
 ServiceSubscription whenever(TypeTag typeTag, ServiceListener<? extends Object> listener)
          Listen for all services of a particular TypeTag in the network.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Unclouded getInstance()
Get a handle to the Unclouded instance.

Returns:
the Unclouded instance.

goOnline

public Network goOnline()
Connect to the network and obtain a network address.

Returns:
An Network object to listen for network status updates.

goOffline

public void goOffline()
Disconnect from the network.


reset

public void reset()
Disconnect from the network and reset the event loop.


broadcast

public ServicePublication broadcast(TypeTag typeTag,
                                    UObject obj)
Broadcast a service referencing an UObject across the network.

An object implementing the UObject interface is passed by reference. When received by the recipient, it is referenced by an RemoteReference.

Parameters:
typeTag - type of the service to be broadcasted.
obj - any object implementing the UObject interface.
Returns:
A ServicePublication instance to manage the publication.

broadcast

public ServicePublication broadcast(TypeTag typeTag,
                                    String s)
Broadcast a service holding a String across the network.

Parameters:
typeTag - type of the service to be broadcasted.
s - the String to broadcast.
Returns:
A ServicePublication instance to manage the publication.

broadcast

public ServicePublication broadcast(TypeTag typeTag,
                                    Integer i)
Broadcast a service holding a Integer across the network.

Parameters:
typeTag - type of the service to be broadcasted.
i - the Integer to broadcast.
Returns:
A ServicePublication instance to manage the publication.

broadcast

public ServicePublication broadcast(TypeTag typeTag,
                                    Double d)
Broadcast a service holding a Double across the network.

Parameters:
typeTag - type of the service to be broadcasted.
d - the Double to broadcast.
Returns:
A ServicePublication instance to manage the publication.

broadcast

public ServicePublication broadcast(TypeTag typeTag,
                                    Serializable serializable)
Broadcast a service holding a Serializable object across the network.

Parameters:
typeTag - type of the service to be broadcasted.
serializable - the serializable object to broadcast.
Returns:
A ServicePublication instance to manage the publication.

when

public ServiceSubscription when(TypeTag typeTag,
                                ServiceListener<? extends Object> listener)
Listen for a single service of a particular TypeTag in the network.

Parameters:
typeTag - type of the service to be discovered.
listener - used to trigger callback methods when status of the discovered service in the network changes.
Returns:
A ServiceSubscription instance to manage the subscription.

whenever

public ServiceSubscription whenever(TypeTag typeTag,
                                    ServiceListener<? extends Object> listener)
Listen for all services of a particular TypeTag in the network.

Parameters:
typeTag - type of the service to be discovered.
listener - used to trigger callback methods when status of the discovered services in the network change.
Returns:
A ServiceSubscription instance to manage the subscription.