Search in sources :

Example 1 with PeerDiscovery

use of com.qualcomm.robotcore.robocol.PeerDiscovery in project robotcode by OutoftheBoxFTC.

the class EventLoopManager method peerDiscoveryEvent.

public CallbackResult peerDiscoveryEvent(RobocolDatagram packet) throws RobotCoreException {
    networkConnectionHandler.updateConnection(packet, null, this);
    // Send a second PeerDiscovery() packet in response. That will inform the fellow
    // who sent the incoming PeerDiscovery() who *we* are.
    // 
    // We should still send a peer discovery packet even if *we* already know the client,
    // because it could be that the connection dropped (e.g., while changing other settings)
    // and the other guy (ie: DS) needs to reconnect. If we don't send this, the connection will
    // never complete. These only get sent about once per second so it's not a huge load on the network.
    PeerDiscovery outgoing = new PeerDiscovery(PeerDiscovery.PeerType.PEER);
    RobocolDatagram outgoingDatagram = new RobocolDatagram(outgoing);
    networkConnectionHandler.sendDatagram(outgoingDatagram);
    return CallbackResult.HANDLED;
}
Also used : PeerDiscovery(com.qualcomm.robotcore.robocol.PeerDiscovery) RobocolDatagram(com.qualcomm.robotcore.robocol.RobocolDatagram)

Aggregations

PeerDiscovery (com.qualcomm.robotcore.robocol.PeerDiscovery)1 RobocolDatagram (com.qualcomm.robotcore.robocol.RobocolDatagram)1