Implemented OfferWriter and RequestWriter, made all the writers

reusable (though not thread-safe), and guiced the readers.
This commit is contained in:
akwizgran
2011-07-26 21:36:55 +01:00
parent 426e415676
commit 9e78837055
23 changed files with 249 additions and 46 deletions

View File

@@ -15,19 +15,15 @@ class SubscriptionWriterImpl implements SubscriptionWriter {
private final OutputStream out;
private final Writer w;
private boolean used = false;
SubscriptionWriterImpl(OutputStream out, WriterFactory writerFactory) {
this.out = out;
w = writerFactory.createWriter(out);
}
public void writeSubscriptions(Collection<Group> subs) throws IOException {
if(used) throw new IllegalStateException();
w.writeUserDefinedTag(Tags.SUBSCRIPTIONS);
w.writeList(subs);
w.writeInt64(System.currentTimeMillis());
out.flush();
used = true;
}
}