public class Carrier
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Carrier.Options
Options defines several settings that control the way the Carrier node
connects to the carrier network.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
CARRIER_MAX_USER_NAME_LEN
Carrier App message max length.
|
static int |
MAX_ID_LEN
Max Carrier ID length.
|
static int |
MAX_KEY_LEN
Max Carrier KEY length.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acceptFriend(java.lang.String userId)
Accept the friend request.
|
void |
addFriend(java.lang.String address,
java.lang.String hello)
Add friend by sending a new friend request.
|
static Carrier |
createInstance(Carrier.Options options,
CarrierHandler handler)
Create node instance.
|
protected void |
finalize() |
java.lang.String |
getAddress()
Get node address associated with the carrier node instance.
|
FriendInfo |
getFriend(java.lang.String userId)
Get specified friend information.
|
java.util.List<FriendInfo> |
getFriends()
Get friends list.
|
java.util.Collection<Group> |
getGroups()
Get groups in the Carrier instance.
|
static java.lang.String |
getIdFromAddress(java.lang.String address)
Get carrier ID from carrier node address.
|
java.lang.String |
getNodeId()
Get nodeid associated with the carrier node instance.
|
int |
getNospam()
\~Egnlish
Get the nospam for Carrier address.
|
PresenceStatus |
getPresence()
Get self presence status.
|
UserInfo |
getSelfInfo()
Get self user information.
|
java.lang.String |
getUserId()
Get userid associated with the carrier node instance.
|
static java.lang.String |
getVersion()
Get current version of Carrier node.
|
Group |
groupJoin(java.lang.String friendId,
byte[] cookie)
Join a group associating with cookie into which remote friend invites.
|
void |
groupLeave(Group group)
Leave a group.
|
void |
inviteFriend(java.lang.String to,
java.lang.String data,
FriendInviteResponseHandler handler)
Send invite request to a friend.
|
boolean |
isFriend(java.lang.String userId)
Check if the user ID is friend.
|
boolean |
isReady()
\~English
Check if carrier node instance is being ready.
|
static boolean |
isValidAddress(java.lang.String address)
Check if the carrier node address is valid.
|
static boolean |
isValidId(java.lang.String id)
Check if the ID is Carrier node id.
|
void |
kill()
Disconnect carrier node from carrier network, and destroy all associated resources to
carreier node instance.
|
void |
labelFriend(java.lang.String userId,
java.lang.String label)
Set the label of the specified friend.
|
Group |
newGroup()
Create a new group.
|
void |
removeFriend(java.lang.String userId)
Remove a friend.
|
void |
replyFriendInvite(java.lang.String to,
int status,
java.lang.String reason,
java.lang.String data)
Reply the friend invite request.
|
long |
sendFriendMessage(java.lang.String to,
byte[] message,
FriendMessageReceiptHandler handler)
Send a message to a friend.
|
long |
sendFriendMessage(java.lang.String to,
java.lang.String message,
FriendMessageReceiptHandler handler)
Send a message to a friend.
|
void |
setNospam(int nospam)
Update self nospam of address for this carrier node.
|
void |
setPresence(PresenceStatus presence)
Update self presence status.
|
void |
setSelfInfo(UserInfo userinfo)
Update self user information.
|
void |
start(int iterateInterval)
Start carrier node asynchronously to connect to carrier network.
|
public static final int MAX_ID_LEN
public static final int MAX_KEY_LEN
public static final int CARRIER_MAX_USER_NAME_LEN
public static java.lang.String getVersion()
public static boolean isValidId(java.lang.String id)
id - The carrier node id to be check.public static boolean isValidAddress(java.lang.String address)
address - The carrier node address to be check.public static java.lang.String getIdFromAddress(java.lang.String address)
address - The carrier node address.public static Carrier createInstance(Carrier.Options options, CarrierHandler handler) throws CarrierException
options - The options to set for creating carrier node.handler - The interface handler for carrier node.CarrierException - carrier exception.protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic void start(int iterateInterval)
iterateInterval - Internal loop interval, in milliseconds.public void kill()
public java.lang.String getAddress()
throws CarrierException
CarrierException - carrier exception.public java.lang.String getNodeId()
throws CarrierException
CarrierException - carrier exception.public java.lang.String getUserId()
throws CarrierException
CarrierException - carrier exception.public void setNospam(int nospam)
throws CarrierException
nospam - An integer value.CarrierException - carrier exception.public int getNospam()
throws CarrierException
CarrierException - carrier exception.public void setSelfInfo(UserInfo userinfo) throws CarrierException
userinfo - The user information to update for this carrier node.java.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public UserInfo getSelfInfo() throws CarrierException
CarrierException - carrier exception.public void setPresence(PresenceStatus presence) throws CarrierException
presence - the new presence status.java.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public PresenceStatus getPresence() throws CarrierException
CarrierException - carrier exception.public boolean isReady()
public java.util.List<FriendInfo> getFriends() throws CarrierException
CarrierException - carrier exception.public FriendInfo getFriend(java.lang.String userId) throws CarrierException
userId - The user identifier of friendjava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public void labelFriend(java.lang.String userId,
java.lang.String label)
throws CarrierException
userId - The friend's user identifierlabel - The new label of specified friendjava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public boolean isFriend(java.lang.String userId)
throws CarrierException
userId - The userId to checkjava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public void addFriend(java.lang.String address,
java.lang.String hello)
throws CarrierException
address - the target user address of remote carrier node.hello - PIN for target user, or any application defined contentjava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public void acceptFriend(java.lang.String userId)
throws CarrierException
userId - The user id who want be friend with us.java.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public void removeFriend(java.lang.String userId)
throws CarrierException
userId - The target user id to remove friendshipjava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public long sendFriendMessage(java.lang.String to,
java.lang.String message,
FriendMessageReceiptHandler handler)
throws CarrierException
to - The target idmessage - The message content defined by applicationhandler - The handler to receive the receipt notification.java.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public long sendFriendMessage(java.lang.String to,
byte[] message,
FriendMessageReceiptHandler handler)
throws CarrierException
to - The target idmessage - The message content defined by applicationhandler - The handler to receive the receipt notification.java.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public void inviteFriend(java.lang.String to,
java.lang.String data,
FriendInviteResponseHandler handler)
throws CarrierException
to - The target iddata - The application defined data send to target userhandler - The handler to receive invite reponsejava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public void replyFriendInvite(java.lang.String to,
int status,
java.lang.String reason,
java.lang.String data)
throws CarrierException
to - The id who send invite requeststatus - The status code of the response. 0 is success, otherwise is errorreason - The error message if status is error, or null if successdata - The application defined data send to target user. If the status
is error, this will be ignoredjava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public Group newGroup() throws CarrierException
CarrierException - carrier exception.public Group groupJoin(java.lang.String friendId, byte[] cookie) throws CarrierException
friendId - The friend who send a group invitationcookie - The cookie information to join groupjava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public void groupLeave(Group group) throws CarrierException
group - The instance of the group to leavejava.lang.IllegalArgumentException - illegal exception.CarrierException - carrier exception.public java.util.Collection<Group> getGroups()