コード例 #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;
 }
コード例 #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;
  }
コード例 #3
0
 public static RUDPPacket createConnectionRequestPacket(RemoteMachine receiver)
     throws UnsupportedEncodingException {
   RUDPPacket packet = new RUDPPacket(receiver);
   packet.setPacketType(PacketType.CON_CREATE);
   return packet;
 }
コード例 #4
0
 public static RUDPPacket createKeepAlivePacket(RemoteMachine server) {
   RUDPPacket packet = new RUDPPacket(server);
   packet.setPacketType(PacketType.KEEP_ALIVE);
   return packet;
 }
コード例 #5
0
 public static RUDPPacket createPollPacket(RemoteMachine server) {
   RUDPPacket packet = new RUDPPacket(server);
   packet.setPacketType(PacketType.POLL);
   return packet;
 }
コード例 #6
0
 public static RUDPPacket createConnectionReplyPacket(RemoteMachine receiver) {
   RUDPPacket packet = new RUDPPacket(receiver);
   packet.setPacketType(PacketType.CON_ACCEPT);
   return packet;
 }