Skip to content

Instantly share code, notes, and snippets.

@john77eipe
Created August 24, 2016 09:11
Show Gist options
  • Save john77eipe/335bc0e456f42556b6c2ba413b054e0d to your computer and use it in GitHub Desktop.
Save john77eipe/335bc0e456f42556b6c2ba413b054e0d to your computer and use it in GitHub Desktop.
private AtomicInteger counter = new AtomicInteger(1);
private boolean sendMessage(PrintWriter writer, WeatherToken token) {
writer.print("id: ");
writer.println(counter.getAndIncrement());
writer.println("event: city");
writer.print("data: ");
writer.println(token.getType()+":"+token.getData());
writer.println(); //new line marks an event boundary
return writer.checkError(); //checkError() calls writer.flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment