diff options
Diffstat (limited to 'sem5/oop/m7/src/Message.java')
-rw-r--r-- | sem5/oop/m7/src/Message.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sem5/oop/m7/src/Message.java b/sem5/oop/m7/src/Message.java new file mode 100644 index 0000000..cad2240 --- /dev/null +++ b/sem5/oop/m7/src/Message.java @@ -0,0 +1,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 {} +} + |