public abstract class DatagramSessionHandler extends java.lang.Object implements SessionHandlerInterface, java.lang.Runnable
Implementation of a session handler that uses a Java datagram socket to listen for incoming requests.
Modifier | Constructor and Description |
---|---|
protected |
DatagramSessionHandler(java.lang.String name,
java.lang.String protocol,
NetworkServer server,
java.net.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
|
java.net.InetAddress |
getBindAddres()
Return the network address that the server should bind to
|
protected java.net.DatagramSocket |
getDatagramSocket()
Return the datagrma socket
|
java.lang.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
|
java.lang.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(java.net.DatagramPacket pkt)
Process a received datagram packet
|
void |
run()
Socket listener thread
|
protected void |
sendDatagram(java.net.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(java.lang.String name, java.lang.String protocol, NetworkServer server, java.net.InetAddress addr, int port)
name
- Stringprotocol
- Stringserver
- NetworkServeraddr
- InetAddressport
- intpublic final int getMaximumDatagramSize()
public final java.lang.String getHandlerName()
getHandlerName
in interface SessionHandlerInterface
public final java.lang.String getProtocolName()
public final boolean hasBindAddress()
public final java.net.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 java.net.DatagramSocket getDatagramSocket()
public void initializeSessionHandler(NetworkServer server) throws java.io.IOException
initializeSessionHandler
in interface SessionHandlerInterface
server
- NetworkServerjava.io.IOException
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(java.net.DatagramPacket pkt) throws java.io.IOException
pkt
- DatagramPacketjava.io.IOException
protected byte[] allocateBuffer(int bufSize)
bufSize
- intprotected void sendDatagram(java.net.DatagramPacket pkt) throws java.io.IOException
pkt
- DatagramPacketjava.io.IOException
public void run()
run
in interface java.lang.Runnable
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.