Package org.openwebnet4j.communication
Class FrameChannel
- java.lang.Object
-
- org.openwebnet4j.communication.FrameChannel
-
public class FrameChannel extends Object
Class that wraps input/output streams to send and receive frames from a OpenWebNet gateway- Author:
- M. Valla - Initial contribution
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
handshakeCompleted
protected Queue<String>
readFrames
-
Constructor Summary
Constructors Modifier Constructor Description protected
FrameChannel(InputStream in, OutputStream out, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
disconnect()
protected String
getName()
protected String
readFrames()
Returns the first frame String from thereadFrames
queue.protected void
sendFrame(String frame)
Sends a frame on the channel
-
-
-
Constructor Detail
-
FrameChannel
protected FrameChannel(InputStream in, OutputStream out, String name)
-
-
Method Detail
-
getName
protected String getName()
-
sendFrame
protected void sendFrame(String frame) throws IOException
Sends a frame on the channel- Parameters:
frame
- the frame- Throws:
IOException
- in case of problems while writing on the OutputStream
-
readFrames
protected String readFrames() throws IOException
Returns the first frame String from thereadFrames
queue. If queue is empty, tries to read (blocking read) available data from InputStream and extract all frames terminated with "##" putting them in thereadFrames
queue. If no new frame can be read from InputStream because end of steam reached, returns null.- Returns:
- the first frame already in the receiving queue, or the first new frame read from InputStream, or null if end of steam reached
- Throws:
IOException
- in case of problems while reading frames from InputStream
-
disconnect
protected void disconnect()
-
-