Java TransmissionManager Example

Introduction

The java transmissionmanager example is extracted from the most popular open source projects, you can refer to the following example for usage.

Programming language: Java

Namespace/package name: it.unipd.vanets.framework.wificonnection.transmissionmanager

Example#1
File: AppController.javaProject: podilaaditya/fastBroadcast

  /**
   * 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();
  }

Example#2
File: AppController.javaProject: podilaaditya/fastBroadcast

 private void sendUnicast(String recipient, IMessage message) {
   TransmissionManager.getInstance().sendUnicast(recipient, message);
 }

Example#3
File: AppController.javaProject: podilaaditya/fastBroadcast

 private void sendBroadcast(IMessage message) {
   TransmissionManager.getInstance()
       .sendBroadcast(new ArrayList<String>(peerIdIpMap.values()), message);
 }