public class Network
extends java.lang.Object
Network.State.CONNECTED using connect()
before sendCommand(Command, CommandStatusListener).
Network.State of a network can be determined using getStatus()
and can be later disconnected using disconnect().| Modifier and Type | Class and Description |
|---|---|
static class |
Network.AccessType
An enum indicating the accessType of the user in a given network.
|
static class |
Network.CommandId
An enum representing the possible commands that can be sent to manage a network.
|
static interface |
Network.CommandStatusListener<T extends CommandResponse<Network.CommandId>>
The listener for status updates of sent commands
sendCommand(Command, CommandStatusListener). |
static class |
Network.CreateChannel
A command for creating a channel in the network.
|
static class |
Network.CreateChannelResponse
Response for
Network.CreateChannel command. |
static class |
Network.DeleteChannel
A command for deleting a channel in the network.
|
static class |
Network.DeleteChannelResponse
A response for
Network.DeleteChannel command. |
static class |
Network.GetAvailableChannels
A command for getting all available channels in the network.
|
static class |
Network.GetAvailableChannelsResponse
A response for
Network.GetAvailableChannels command. |
static interface |
Network.MessagingListener
The listener for listening to content info and messages sent by other nodes.
|
static class |
Network.Role
An enum indicating the role of the user in a given network.
|
static class |
Network.State
Determines the connection status of the network.
|
static class |
Network.Type
Determines the type of the network.
|
| Modifier and Type | Field and Description |
|---|---|
static long |
MANAGEMENT_NODE_ID |
| Modifier | Constructor and Description |
|---|---|
protected |
Network(java.lang.String networkId) |
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
connect to this network.
|
void |
disconnect()
disconnect from this network.
|
Network.AccessType |
getAccessType()
Get the access type of the current user for this network.
|
java.lang.String |
getId()
Get the unique ID of this network.
|
java.lang.String |
getMetadata() |
java.lang.String |
getName() |
Network.State |
getStatus() |
Network.Type |
getType() |
Network.Role |
getUserRole()
Get the role of the current user for this network.
|
protected void |
internalNodeConnectionStatusCallback(long nodeId,
boolean isOnline) |
protected void |
internalOnContentInfoMessageReceived(java.lang.String message,
long sourceNodeId,
int contentTime) |
protected void |
internalOnMessageReceived(java.lang.String message,
long sourceNodeId) |
protected void |
internalSetMetadata(java.lang.String networkMetadata) |
protected void |
internalSetName(java.lang.String networkName) |
protected void |
internalSetStatus(Network.State networkStatus) |
protected void |
internalSetType(Network.Type networkType) |
<V extends CommandResponse<Network.CommandId>,U extends Command<Network.CommandId,V>> |
sendCommand(U command,
Network.CommandStatusListener<V> listener) |
void |
sendContentInfoMessage(java.lang.String message,
int contentTime,
long... destinationNodes)
Send content info message to the specified nodes.
|
void |
sendMessage(java.lang.String message,
long... destinationNodes)
Send message to the specified nodes.
|
void |
setMessagingListener(Network.MessagingListener listener)
set the message listener for this network.
|
java.lang.String |
toString() |
public static final long MANAGEMENT_NODE_ID
public java.lang.String getId()
protected void internalOnMessageReceived(java.lang.String message,
long sourceNodeId)
protected void internalOnContentInfoMessageReceived(java.lang.String message,
long sourceNodeId,
int contentTime)
protected void internalNodeConnectionStatusCallback(long nodeId,
boolean isOnline)
protected void internalSetMetadata(java.lang.String networkMetadata)
protected void internalSetName(java.lang.String networkName)
protected void internalSetType(Network.Type networkType)
protected void internalSetStatus(Network.State networkStatus)
public java.lang.String getMetadata()
public java.lang.String getName()
public Network.Type getType()
public Network.State getStatus()
public Network.Role getUserRole()
public Network.AccessType getAccessType()
public void setMessagingListener(Network.MessagingListener listener)
listener - The interface which will be triggered on new messages.
Pass null to unset previous listeners.public void sendMessage(java.lang.String message,
long... destinationNodes)
message - The message which has to be transmitteddestinationNodes - The target nodes which will receive this message,
pass nothing (or) null for broadcasting.public void sendContentInfoMessage(java.lang.String message,
int contentTime,
long... destinationNodes)
message - The message which has to be passed along with thiscontentTime - The Content sync time in millis
NOTE: passing other time units will cause issuesdestinationNodes - The target nodes which will receive this message,
pass nothing (or) null for broadcasting.public void connect()
public void disconnect()
public <V extends CommandResponse<Network.CommandId>,U extends Command<Network.CommandId,V>> void sendCommand(U command, Network.CommandStatusListener<V> listener)
public java.lang.String toString()
toString in class java.lang.Object