-
Notifications
You must be signed in to change notification settings - Fork 0
/
AckPacketContent.java
63 lines (54 loc) · 1.2 KB
/
AckPacketContent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* Class for packet content that represents acknowledgements
*
*/
public class AckPacketContent extends PacketContent {
String info;
/**
* Constructor that takes in information about a file.
* @param info Acknowledgment Info.
*/
AckPacketContent(String info) {
type= ACKPACKET;
this.info = info;
}
/**
* Constructs an object out of a datagram packet.
* @param packet Packet that contains information about a file.
*/
protected AckPacketContent(ObjectInputStream oin) {
try {
type= ACKPACKET;
info= oin.readUTF();
}
catch(Exception e) {e.printStackTrace();}
}
/**
* Writes the content into an ObjectOutputStream
*
*/
protected void toObjectOutputStream(ObjectOutputStream oout) {
try {
oout.writeUTF(info);
}
catch(Exception e) {e.printStackTrace();}
}
/**
* Returns the content of the packet as String.
*
* @return Returns the content of the packet as String.
*/
public String toString() {
return "ACK:" + info;
}
/**
* Returns the info contained in the packet.
*
* @return Returns the info contained in the packet.
*/
public String getPacketInfo() {
return info;
}
}