Exemplo n.º 1
0
 public static RUDPPacket createAckPacket(RUDPPacket rudpPacket, int seqNumber) {
   RUDPPacket packet = new RUDPPacket();
   packet.setPacketType(PacketType.PAYLOAD_ACK);
   packet.setSeqNumber(seqNumber);
   packet.setReceiver(rudpPacket.getSender());
   return packet;
 }
Exemplo n.º 2
0
  public static RUDPPacket createPayloadPacket(RemoteMachine server, Object o) throws IOException {
    RUDPPacket packet = new RUDPPacket(server);
    packet.setPacketType(PacketType.PAYLOAD);

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(o);
    oos.flush();
    oos.close();
    bos.close();

    packet.setPayload(bos.toByteArray());

    return packet;
  }
Exemplo n.º 3
0
 public static RUDPPacket createConnectionRequestPacket(RemoteMachine receiver)
     throws UnsupportedEncodingException {
   RUDPPacket packet = new RUDPPacket(receiver);
   packet.setPacketType(PacketType.CON_CREATE);
   return packet;
 }
Exemplo n.º 4
0
 public static RUDPPacket createKeepAlivePacket(RemoteMachine server) {
   RUDPPacket packet = new RUDPPacket(server);
   packet.setPacketType(PacketType.KEEP_ALIVE);
   return packet;
 }
Exemplo n.º 5
0
 public static RUDPPacket createPollPacket(RemoteMachine server) {
   RUDPPacket packet = new RUDPPacket(server);
   packet.setPacketType(PacketType.POLL);
   return packet;
 }
Exemplo n.º 6
0
 public static RUDPPacket createConnectionReplyPacket(RemoteMachine receiver) {
   RUDPPacket packet = new RUDPPacket(receiver);
   packet.setPacketType(PacketType.CON_ACCEPT);
   return packet;
 }