public abstract class AisReader extends Thread
| Modifier and Type | Class and Description |
|---|---|
static class |
AisReader.Status
The enum Status.
|
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected CopyOnWriteArrayList<Consumer<AisMessage>> |
handlers
List receivers for the AIS messages.
|
protected CopyOnWriteArrayList<Consumer<? super AisPacket>> |
packetHandlers
List of packet handlers.
|
protected SendThreadPool |
sendThreadPool
A pool of sending threads.
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
AisReader() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
distribute(AisPacket packet)
Distribute.
|
protected void |
doSend(SendRequest sendRequest,
Consumer<Abk> resultListener,
OutputStream out)
The method to do the actual sending
|
long |
getNumberOfBytesRead()
Gets number of bytes read.
|
long |
getNumberOfBytesWritten()
Gets number of bytes written.
|
long |
getNumberOfLinesRead()
Gets number of lines read.
|
String |
getSourceId()
Gets source id.
|
abstract AisReader.Status |
getStatus()
Get the status of the connection, either connected or disconnected
|
protected boolean |
isShutdown()
Is shutdown boolean.
|
protected void |
readLoop(InputStream stream)
The main read loop to use if sentences in stream
|
void |
registerHandler(Consumer<AisMessage> aisHandler)
Add an AIS handler
|
void |
registerPacketHandler(Consumer<? super AisPacket> packetConsumer)
Add a packet handler
|
void |
registerQueue(IMessageQueue<AisMessage> queue)
Add a queue for receiving messages
|
void |
registerQueueHandler(IQueueEntryHandler<AisMessage> handler)
Make a new queue and reader for the queue.
|
Abk |
send(AisMessage aisMessage,
int sequence,
int destination)
Sending with 60 sec default timeout
|
Abk |
send(AisMessage aisMessage,
int sequence,
int destination,
int timeout)
Blocking method to send message in an easy way
|
abstract void |
send(SendRequest sendRequest,
Consumer<Abk> resultListener)
Method to send addressed or broadcast AIS messages (ABM or BBM).
|
void |
setSourceId(String sourceId)
Sets source id.
|
void |
stopReader()
Stop the reader
|
AisPacketStream |
stream()
Returns a ais packet stream.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected final CopyOnWriteArrayList<Consumer<AisMessage>> handlers
protected final CopyOnWriteArrayList<Consumer<? super AisPacket>> packetHandlers
protected final SendThreadPool sendThreadPool
protected void doSend(SendRequest sendRequest, Consumer<Abk> resultListener, OutputStream out) throws SendException
sendRequest - the send requestresultListener - the result listenerout - the outSendException - the send exceptionpublic long getNumberOfBytesRead()
public long getNumberOfBytesWritten()
public long getNumberOfLinesRead()
public String getSourceId()
public abstract AisReader.Status getStatus()
protected boolean isShutdown()
protected void readLoop(InputStream stream) throws IOException
stream - the generic input stream to read fromIOException - the io exceptionprotected void distribute(AisPacket packet)
packet - the packetpublic void registerHandler(Consumer<AisMessage> aisHandler)
aisHandler - the ais handlerpublic void registerPacketHandler(Consumer<? super AisPacket> packetConsumer)
packetConsumer - the packet consumerpublic void registerQueue(IMessageQueue<AisMessage> queue)
queue - the queuepublic void registerQueueHandler(IQueueEntryHandler<AisMessage> handler)
handler - the handlerpublic Abk send(AisMessage aisMessage, int sequence, int destination) throws SendException, InterruptedException
aisMessage - the ais messagesequence - the sequencedestination - the destinationSendException - the send exceptionInterruptedException - the interrupted exceptionpublic Abk send(AisMessage aisMessage, int sequence, int destination, int timeout) throws SendException, InterruptedException
aisMessage - the ais messagesequence - the sequencedestination - the destinationtimeout - the timeoutSendException - the send exceptionInterruptedException - the interrupted exceptionpublic abstract void send(SendRequest sendRequest, Consumer<Abk> resultListener) throws SendException
sendRequest - the send requestresultListener - A class to handle the result when it is ready.SendException - the send exceptionpublic void setSourceId(String sourceId)
sourceId - the source idpublic void stopReader()
public AisPacketStream stream()
Copyright © 2011–2019 Danish Maritime Authority. All rights reserved.