Package agentj.examples.udprouting

Examples of agentj.examples.udprouting.Message


      public void run(){
        DatagramPacket packet = new DatagramPacket(buf, buf.length, _broadcast, Constants.PORT);
       
       
        try {
          Message msg = new Message(buf, buf.length);
          StringBuffer txt = new StringBuffer("Forwarding ");
          txt.append(msg.toString());
          _logger.info(txt.toString());
          _socket.send(packet);
        } catch (IOException e) {
          e.printStackTrace();
        } catch (Exception e) {
View Full Code Here


        _socket.receive(packet);
       
        if (packet.getAddress().equals(_router.getOrigAddress()))
          continue;
       
        Message message = new Message(packet.getData(), packet.getLength());
        Short seqno = message.getSeqno();
        if (message.getMsgType() == Message.HELLO)
          message.setOrigAddress(packet.getAddress());
       
        if (!_receivedSet.contains(message.getOrigAddress(), seqno) && !message.getOrigAddress().equals(_origAddress)){
          StringBuffer txt = new StringBuffer("Received ");
          txt.append(message.toString());
          _logger.info(txt.toString());
          _receivedSet.add(new ReceivedTuple(message.getOrigAddress(), seqno));
         
          if (message.getMsgType() == Message.HELLO)
            _router.processHello(message);
          else if (message.getMsgType() == Message.TC)
            _router.processTc(message);
        }
      } catch (Exception e) {
        _logger.warning("Error parsing packet");
        e.printStackTrace();
View Full Code Here

TOP

Related Classes of agentj.examples.udprouting.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.