public void onPeerLeave(DeviceInfo dev) {
   Bundle b = Utils.device2Bundle(dev);
   b.putString(Router.MsgKey.GROUP_ID, groupId);
   Message m = Message.obtain(null, MsgId.PEER_LEAVE);
   m.setData(b);
   recvMsg(m);
 }
 public void onGetPeerDevices(DeviceInfo[] devices) {
   Bundle b = Utils.deviceArray2Bundle(devices);
   b.putString(Router.MsgKey.GROUP_ID, groupId);
   Message m = Message.obtain(null, MsgId.GET_CONNECTED_PEERS);
   m.setData(b);
   recvMsg(m);
 }
 public void onConnecting(DeviceInfo device, byte[] token) {
   Message m = Message.obtain(null, MsgId.CONNECTING);
   Bundle b = Utils.device2Bundle(device);
   b.putByteArray(Router.MsgKey.AUTHENTICATION_TOKEN, token);
   m.setData(b);
   recvMsg(m);
 }
 public void onSelfJoin(DeviceInfo[] devs) {
   Bundle b = Utils.deviceArray2Bundle(devs);
   b.putString(Router.MsgKey.GROUP_ID, groupId);
   Message m = Message.obtain(null, MsgId.SELF_JOIN);
   m.setData(b);
   recvMsg(m);
 }
 public void onSearchFoundDevice(DeviceInfo device, boolean useSSL) {
   Message m = Message.obtain(null, MsgId.SEARCH_FOUND_DEVICE);
   Bundle b = Utils.device2Bundle(device);
   b.putBoolean(Router.MsgKey.USE_SSL, useSSL);
   m.setData(b);
   recvMsg(m);
 }
        public void onConnectionFailed(DeviceInfo device, int rejectCode) {
          Message m = Message.obtain(null, MsgId.CONNECTION_FAILED);
          Bundle b = Utils.device2Bundle(device);
          b.putInt(Router.MsgKey.CONN_DENY_CODE, rejectCode);
          m.setData(b);

          recvMsg(m);
        }
 @Override
 public void onNetworkConnectionFailed(NetInfo net) {
   Message m = Message.obtain(null, MsgId.NETWORK_CONNECTION_FAILED);
   m.setData(Utils.net2Bundle(net));
   recvMsg(m);
 }
 @Override
 public void onNetworkActivated(NetInfo net) {
   Message m = Message.obtain(null, MsgId.ACTIVATE_NETWORK);
   m.setData(Utils.net2Bundle(net));
   recvMsg(m);
 }
 @Override
 public void onNetworkDisconnected(NetInfo net) {
   Message m = Message.obtain(null, MsgId.NETWORK_DISCONNECTED);
   m.setData(Utils.net2Bundle(net));
   recvMsg(m);
 }
 @Override
 public void onGetActiveNetwork(NetInfo net) {
   Message m = Message.obtain(null, MsgId.GET_ACTIVE_NETWORK);
   m.setData(Utils.net2Bundle(net));
   recvMsg(m);
 }
 @Override
 public void onGetNetworks(NetInfo[] nets) {
   Message m = Message.obtain(null, MsgId.GET_NETWORKS);
   m.setData(Utils.netArray2Bundle(nets));
   recvMsg(m);
 }
 public void onSearchStart(DeviceInfo leader) {
   Message m = Message.obtain(null, MsgId.SEARCH_START);
   m.setData(Utils.device2Bundle(leader));
   recvMsg(m);
 }
 public void onGetPeerDevices(DeviceInfo[] devices) {
   Message m = Message.obtain(null, MsgId.GET_CONNECTED_PEERS);
   m.setData(Utils.deviceArray2Bundle(devices));
   recvMsg(m);
 }
 public void onGetDeviceInfo(DeviceInfo device) {
   Message m = Message.obtain(null, MsgId.GET_DEVICE_INFO);
   m.setData(Utils.device2Bundle(device));
   recvMsg(m);
 }
 public void onDisconnected(DeviceInfo dev) {
   Message m = Message.obtain(null, MsgId.DISCONNECTED);
   m.setData(Utils.device2Bundle(dev));
   recvMsg(m);
 }