29 lines
584 B
Java
29 lines
584 B
Java
package meerkat.comm;
|
|
|
|
import com.google.protobuf.Message;
|
|
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
|
|
/**
|
|
* Created by Arbel Deutsch Peled on 21-Feb-16.
|
|
* An output stream of Protobuf messages
|
|
*/
|
|
public class MessageOutputStream<T extends Message> {
|
|
|
|
private OutputStream out;
|
|
|
|
public MessageOutputStream(OutputStream out) throws IOException {
|
|
this.out = out;
|
|
}
|
|
|
|
public void writeMessage(T message) throws IOException {
|
|
message.writeDelimitedTo(out);
|
|
}
|
|
|
|
public void close() throws IOException {
|
|
out.close();
|
|
}
|
|
|
|
}
|