-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJumpPacket.java
66 lines (57 loc) · 1.2 KB
/
JumpPacket.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
64
65
66
/**
* @author Thomas Moroney
*/
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* Class for packet content that represents file information
*
*/
public class JumpPacket extends PacketContent {
int port;
/**
* Constructor that takes in port of the next node.
* @param port Size of filename.
*/
JumpPacket(int port) {
type= NEXTNODE;
this.port = port;
}
/**
* Constructs an object out of a datagram packet.
* @param packet Packet that contains information about a file.
*/
protected JumpPacket(ObjectInputStream oin) {
try {
type= NEXTNODE;
port= oin.readInt();
}
catch(Exception e) {e.printStackTrace();}
}
/**
* Writes the content into an ObjectOutputStream
*
*/
protected void toObjectOutputStream(ObjectOutputStream oout) {
try {
oout.writeInt(port);
}
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 "Port: " + port;
}
/**
* Returns the port contained in the packet.
*
* @return Returns the port contained in the packet.
*/
public int getPort() {
return port;
}
}