コード例 #1
0
  public void handleDataPacket(Packet p) {
    // this packet is for this device
    if (p.getDestination().equals(localDevice.getBluetoothAddress())) {
      offer(p);
    } else {
      String nextHop = routingTable.nextHop(localDevice.getBluetoothAddress(), p.getDestination());

      if (nextHop != null) {
        Log("SynCore", "Packet from: " + p.getSource() + " routed to: " + nextHop);
        for (String n : connections.keySet()) {
          if (n.equals(nextHop)) {
            connections.get(n).offer(p);
          }
        }
      }
    }
  }
コード例 #2
0
 public void handlePacket(byte[] p, String from) {
   Packet s = Packet.createPacket(p);
   s.decreaseHopCount();
   if (s.getHopCount() > 0) {
     Log("SynCore", s.getSource() + " " + s.getDestination());
     if (s.getType() == Packet.DATA_PACKET) {
       handleDataPacket(s);
     } else {
       handleUpdatePacket(s, from);
     }
   }
 }