Ejemplo n.º 1
0
  /**
   * Constructor
   *
   * @param context
   */
  public AppController(
      Context context, GuiHandlerInterface guiHandlerInterface, TransportSelectorFilter filter) {
    this.context = context;
    this.guiHandler = guiHandlerInterface.getGuiHandler();

    collectionHandler.setWiFiController(this);
    // manager and channel initialization
    manager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE);
    channel = manager.initialize(context, context.getMainLooper(), null);
    // Register intent filter to receive specific intents
    broadcastReceiverIntentFilter = new IntentFilter();
    broadcastReceiverIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
    broadcastReceiverIntentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    broadcastReceiverIntentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
    broadcastReceiverIntentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);

    // Setting static field which contains device MAC address
    MAC_ADDRESS = getDeviceMacAddress();
    logger.d("il MAC address del dispositivo è = " + MAC_ADDRESS);

    // Force creation of TransportManager
    TransmissionManager.getInstance().setFilter(filter);

    register();
  }
Ejemplo n.º 2
0
 private void sendUnicast(String recipient, IMessage message) {
   TransmissionManager.getInstance().sendUnicast(recipient, message);
 }
Ejemplo n.º 3
0
 private void sendBroadcast(IMessage message) {
   TransmissionManager.getInstance()
       .sendBroadcast(new ArrayList<String>(peerIdIpMap.values()), message);
 }