All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nitorcreations.willow.deployer.StreamLinePumper Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.nitorcreations.willow.deployer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;

import com.nitorcreations.willow.messages.OutputMessage;
import com.nitorcreations.willow.messages.WebSocketTransmitter;

class StreamLinePumper implements Runnable {
	private final BufferedReader in;
	private final String name;
	private final WebSocketTransmitter transmitter;

	public StreamLinePumper(InputStream in, WebSocketTransmitter transmitter, String name) throws URISyntaxException {
		this.transmitter = transmitter;
		this.in = new BufferedReader(new InputStreamReader(in));
		this.name = name;
	}
	
	@Override
	public void run() {
		try {
			String line;
			while ((line = in.readLine()) != null) {
				OutputMessage msg = new OutputMessage(name, line);
				transmitter.queue(msg);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy