public abstract class DatagramSessionHandler extends Object implements SessionHandlerInterface, Runnable
Implementation of a session handler that uses a Java datagram socket to listen for incoming requests.
Modifier | Constructor and Description |
---|---|
protected |
DatagramSessionHandler(String name,
String protocol,
NetworkServer server,
InetAddress addr,
int port)
Class constructor
|
Modifier and Type | Method and Description |
---|---|
protected byte[] |
allocateBuffer(int bufSize)
Allocate a buffer for the datagram receive
|
protected void |
clearShutdown()
Clear the shutdown flag
|
void |
closeSessionHandler(NetworkServer server)
Close the session handler
|
InetAddress |
getBindAddres()
Return the network address that the server should bind to
|
protected DatagramSocket |
getDatagramSocket()
Return the datagrma socket
|
String |
getHandlerName()
Return the session handler name
|
int |
getMaximumDatagramSize()
Return the maximum datagram size allowed
|
protected int |
getNextSessionId()
Get the next available session id
|
int |
getPort()
Return the port that the server should bind to
|
String |
getProtocolName()
Return the short protocol name
|
boolean |
hasBindAddress()
Check if the server should bind to a specific network address
|
boolean |
hasDebug()
Determine if debug output is enabled
|
protected boolean |
hasShutdown()
Determine if the shutdown flag has been set
|
void |
initializeSessionHandler(NetworkServer server)
Initialize the session handler
|
protected abstract boolean |
processDatagram(DatagramPacket pkt)
Process a received datagram packet
|
void |
run()
Socket listener thread
|
protected void |
sendDatagram(DatagramPacket pkt)
Send a datagram
|
void |
setDebug(boolean dbg)
Enable/disable debug output
|
protected void |
setMaximumDatagramSize(int maxSize)
Set the maximum datagram size
|
protected void |
setPort(int port)
Set the local port that the datagram handler is using
|
protected DatagramSessionHandler(String name, String protocol, NetworkServer server, InetAddress addr, int port)
name
- Stringprotocol
- Stringserver
- NetworkServeraddr
- InetAddressport
- intpublic final int getMaximumDatagramSize()
public final String getHandlerName()
getHandlerName
in interface SessionHandlerInterface
public final String getProtocolName()
public final boolean hasBindAddress()
public final InetAddress getBindAddres()
public final int getPort()
public final boolean hasDebug()
protected final void clearShutdown()
protected final boolean hasShutdown()
protected int getNextSessionId()
protected final void setPort(int port)
port
- intprotected final DatagramSocket getDatagramSocket()
public void initializeSessionHandler(NetworkServer server) throws IOException
initializeSessionHandler
in interface SessionHandlerInterface
server
- NetworkServerIOException
public void closeSessionHandler(NetworkServer server)
closeSessionHandler
in interface SessionHandlerInterface
server
- NetworkServerpublic final void setDebug(boolean dbg)
dbg
- booleanprotected final void setMaximumDatagramSize(int maxSize)
maxSize
- intprotected abstract boolean processDatagram(DatagramPacket pkt) throws IOException
pkt
- DatagramPacketIOException
protected byte[] allocateBuffer(int bufSize)
bufSize
- intprotected void sendDatagram(DatagramPacket pkt) throws IOException
pkt
- DatagramPacketIOException
Copyright © 2005–2018 Alfresco Software. All rights reserved.