aboutsummaryrefslogtreecommitdiff
path: root/sem5/oop/m7/src/Message.java
blob: cad2240bc15ee77673bea03b12e396e1a9caef0d (plain)
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
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.Random;

public class Message implements Serializable {
	public String from;
	// If too is empty it is for all
	public String to;
	public int id;
	
	public Message(String from, String to) {
		this.from = from;
		this.to = to;
	}
	
	public void send(OutputStream out) throws IOException{
		ObjectOutputStream objout = null;
		try {
			objout = new ObjectOutputStream(out);
			objout.writeObject(this);
		} finally {
			if (objout != null) {
				objout.close();
			}
		}
	}
	
	public void trace(String node) {}
	
	public void handle(Node n) throws Exception {}
}