public static final class Router.MsgId
extends java.lang.Object
Router.MsgKey
class.
include the following groups of message ids:
A sample scenario of using Messenger api to interact with GroupService is as following:
//first bind to messenger service: Intent intent = new Intent("com.xconns.peerdevicenet.Messenger"); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); ...... //then at onServiceConnected(): register a receiver messenger to receive messages: Message msg = Message.obtain(null, Router.MsgId.REGISTER_RECEIVER); msg.replyTo = mMessenger; mService.send(msg);
Message msg = Message.obtain(null, Router.MsgId.SEND_MSG, 0, 0); Bundle b = new Bundle(); b.putByteArray(Router.MSG_DATA, msg_data.getBytes()); b.putString(Router.GROUP_ID, groupId); msg.setData(b); mService.send(msg);
// first tell Router services we are leaving: Message msg = Message.obtain(null, Router.MsgId.LEAVE_GROUP); msg.setData(b); mService.send(msg); // then unregister receiver messenger: msg = Message.obtain(null, Router.MsgId.UNREGISTER_RECEIVER); msg.replyTo = mMessenger; mService.send(msg); // finally unbind messenger service unbindService(mConnection);
For detailed tutorial on how to use messengers talk to GroupService and send/receive messages to peers, please check out the github sample project.
Modifier and Type | Field and Description |
---|---|
static int |
ACCEPT_CONNECTION
message id for accepting a peer's connection request.
|
static int |
ACTIVATE_NETWORK
message id for request and reply to activate
a network for use to discover and connect peer devices.
|
static int |
CONNECT
message id for request to connect to a peer device.
|
static int |
CONNECT_NETWORK
message id to request connecting to a network
|
static int |
CONNECTED
message id to notify client that a peer connected.
|
static int |
CONNECTING
message id to notify client that a peer device is trying
to connect.
|
static int |
CONNECTION_FAILED
message id to notify client that connection to peer failed.
|
static int |
DENY_CONNECTION
message id for denying peer's connection request.
|
static int |
DISCONNECT
message id for request to disconnect a peer device.
|
static int |
DISCONNECT_NETWORK
message id to request disconnecting from a network
|
static int |
DISCONNECTED
message id to notify client that a peer disconnected.
|
static int |
ERROR
message id for Router to return error messages to clients.
|
static int |
GET_ACTIVE_NETWORK
message id for request and reply info of the network
currently used to discover and connect peer devices.
|
static int |
GET_CONNECTED_PEERS
message id for request and reply to get connected peer device info.
|
static int |
GET_CONNECTION_INFO
message id for request and reply of connection related info at ConnectionService.
|
static int |
GET_DEVICE_INFO
message id for request and reply of my device info at ConnectionService.
|
static int |
GET_NETWORKS
message id for request and reply info of networks
currently attached to device.
|
static int |
JOIN_GROUP
message id for request to join a group
|
static int |
LEAVE_GROUP
message id for request to leave a group
|
static int |
NETWORK_CONNECTED
message id to notify clients device is attached to
a new network.
|
static int |
NETWORK_CONNECTING
message id to notify clients that a connection to network is in process
|
static int |
NETWORK_CONNECTION_FAILED
message id to notify clients that connection to a network failed
|
static int |
NETWORK_DISCONNECTED
message id to notify clients device is detached from
a network.
|
static int |
PEER_JOIN
message id to notify client a peer device joined group.
|
static int |
PEER_LEAVE
message id to notify client a peer device left group.
|
static int |
RECV_MSG
message id to notify client to receive a message from peers.
|
static int |
REGISTER_RECEIVER
message id to register a receiver messenger.
|
static int |
SEARCH_COMPLETE
intent action name to notify clients that search session completed, either because search session time out or client stoped search explicitly.
|
static int |
SEARCH_FOUND_DEVICE
message id to notify client that new device found
during search.
|
static int |
SEARCH_START
message id to notify client the search session started.
|
static int |
SELF_JOIN
message id to notify client it has successfully joined a group.
|
static int |
SELF_LEAVE
message id to notify client it has left a group.
|
static int |
SEND_MSG
message id to send a message to peers.
|
static int |
SEND_REMOTE_BROADCAST |
static int |
SET_CONNECTION_INFO
message id for request and reply of setting connection related info in ConnectionService.
|
static int |
START_REMOTE_ACTIVITY |
static int |
START_REMOTE_SERVICE |
static int |
START_SEARCH
message id for request to start a new peer search session.
|
static int |
STOP_SEARCH
message id for request to stop current active peer search session.
|
static int |
UNREGISTER_RECEIVER
message id to unregister a receiver messenger.
|
Constructor and Description |
---|
MsgId() |
public static final int ERROR
Message Data is a bundle indexed by MsgKey:
public static final int START_SEARCH
Message data is a bundle indexed by MsgKey:
public static final int STOP_SEARCH
public static final int SEARCH_START
Message data is a bundle indexed by MsgKey:
public static final int SEARCH_FOUND_DEVICE
Message data is a bundle indexed by MsgKey:
public static final int SEARCH_COMPLETE
public static final int CONNECT
Message data is a bundle indexed by MsgKey:
public static final int DISCONNECT
Message data is a bundle indexed by MsgKey:
public static final int ACCEPT_CONNECTION
Message data is a bundle indexed by MsgKey:
public static final int DENY_CONNECTION
Message data is a bundle indexed by MsgKey:
Connection Failure code
for the reason of denial.public static final int CONNECTING
Message data is a bundle indexed by MsgKey:
public static final int CONNECTION_FAILED
Message data is a bundle indexed by MsgKey:
Connection Failure code
for the reason of denial.public static final int CONNECTED
Message data is a bundle indexed by MsgKey:
public static final int DISCONNECTED
Message data is a bundle indexed by MsgKey:
public static final int JOIN_GROUP
Message data is a bundle indexed by MsgKey:
public static final int LEAVE_GROUP
Message data is a bundle indexed by MsgKey:
public static final int SELF_JOIN
Message data is a bundle indexed by MsgKey:
public static final int PEER_JOIN
Message data is a bundle indexed by MsgKey:
public static final int SELF_LEAVE
Message data is a bundle indexed by MsgKey:
public static final int PEER_LEAVE
Message data is a bundle indexed by MsgKey:
public static final int SEND_MSG
Message data is a bundle indexed by MsgKey:
public static final int RECV_MSG
Message data is a bundle indexed by MsgKey:
public static final int SET_CONNECTION_INFO
Request message data is a bundle indexed by MsgKey:
public static final int GET_CONNECTION_INFO
Reply message data is a bundle indexed by MsgKey:
public static final int GET_DEVICE_INFO
Reply message data is a bundle indexed by MsgKey:
public static final int GET_CONNECTED_PEERS
Request message data is a bundle indexed by MsgKey:
Reply message data is a bundle indexed by MsgKey:
public static final int GET_NETWORKS
Reply Message Data is a bundle indexed by MsgKey:
public static final int GET_ACTIVE_NETWORK
Reply message data is a bundle indexed by MsgKey:
public static final int ACTIVATE_NETWORK
Request and reply message data is a bundle indexed by MsgKey:
public static final int NETWORK_CONNECTED
Message data is a bundle indexed by MsgKey:
public static final int NETWORK_DISCONNECTED
Message data is a bundle indexed by MsgKey:
public static final int CONNECT_NETWORK
Message data is a bundle indexed by MsgKey:
public static final int DISCONNECT_NETWORK
Message data is a bundle indexed by MsgKey:
public static final int NETWORK_CONNECTING
Message data is a bundle indexed by MsgKey:
public static final int NETWORK_CONNECTION_FAILED
Message data is a bundle indexed by MsgKey:
public static final int REGISTER_RECEIVER
Message data:
public static final int UNREGISTER_RECEIVER
Message data:
public static final int START_REMOTE_ACTIVITY
public static final int START_REMOTE_SERVICE
public static final int SEND_REMOTE_BROADCAST