|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.nio.conman.Connection
com.threerings.presents.server.net.PresentsConnection
public class PresentsConnection
Parses incoming network data into a stream of Message objects, sends messages to the
client and adds datagram support to a connection.
| Nested Class Summary | |
|---|---|
static interface |
PresentsConnection.MessageHandler
Used with setMessageHandler(com.threerings.presents.server.net.PresentsConnection.MessageHandler). |
| Field Summary | |
|---|---|
protected InetSocketAddress |
_datagramAddress
|
protected DatagramChannel |
_datagramChannel
|
protected byte[] |
_datagramSecret
|
protected MessageDigest |
_digest
|
protected FramedInputStream |
_fin
|
protected PresentsConnection.MessageHandler |
_handler
|
protected ClassLoader |
_loader
|
protected ObjectInputStream |
_oin
|
protected ObjectOutputStream |
_oout
|
protected PresentsConnectionManager |
_pcmgr
|
protected DatagramSequencer |
_sequencer
|
protected boolean |
_transmitDatagrams
|
| Fields inherited from class com.threerings.nio.conman.Connection |
|---|
_channel, _cmgr, _connectionId, _lastConnectionId, _lastEvent, selkey |
| Constructor Summary | |
|---|---|
PresentsConnection()
|
|
| Method Summary | |
|---|---|
void |
clearMessageHandler()
Clears out our message handler, causing any subsequent messages to be dropped on arrival. |
protected ObjectInputStream |
createObjectInputStream(InputStream src)
Creates the object input stream used by this connection to communicate. |
InetSocketAddress |
getDatagramAddress()
Returns the address to which datagrams should be sent or null if no datagram address has been established. |
DatagramChannel |
getDatagramChannel()
Returns the channel through which datagrams should be sent or null if no datagram channel has been established. |
protected DatagramSequencer |
getDatagramSequencer()
Returns a reference to the connection's datagram sequencer. |
protected ObjectInputStream |
getObjectInputStream()
Returns the object input stream associated with this connection. |
protected ObjectOutputStream |
getObjectOutputStream(FramingOutputStream fout)
Returns the object output stream associated with this connection (creating it if necessary). |
boolean |
getTransmitDatagrams()
Checks whether we should transmit datagrams. |
void |
handleDatagram(InetSocketAddress source,
DatagramChannel channel,
ByteBuffer buf,
long when)
Processes a datagram sent to this connection. |
int |
handleEvent(long when)
Called when a network event has occurred on this handler's source. |
protected void |
inheritStreams(PresentsConnection other)
Instructs this connection to inherit its streams from the supplied connection object. |
void |
init(ConnectionManager cmgr,
SocketChannel channel,
long createStamp)
Initializes the connection with its channel. |
void |
postMessage(Message msg)
Posts a message for delivery to this connection. |
void |
setClassLoader(ClassLoader loader)
Configures this connection with a custom class loader. |
void |
setDatagramSecret(String secret)
Sets the secret string used to authenticate datagrams from the client. |
void |
setMessageHandler(PresentsConnection.MessageHandler handler)
Instructs the connection to pass parsed messages on to this handler for processing. |
protected void |
setObjectOutputStream(ObjectOutputStream oout)
Sets the object output stream used by this connection. |
void |
setTransmitDatagrams(boolean transmit)
Sets whether we should transmit datagrams. |
| Methods inherited from class com.threerings.nio.conman.Connection |
|---|
asyncClose, becameIdle, checkIdle, close, closeSocket, connectFailure, getChannel, getConnectionId, getInetAddress, isClosed, networkFailure, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected FramedInputStream _fin
protected ObjectInputStream _oin
protected ObjectOutputStream _oout
protected InetSocketAddress _datagramAddress
protected DatagramChannel _datagramChannel
protected byte[] _datagramSecret
protected boolean _transmitDatagrams
protected MessageDigest _digest
protected DatagramSequencer _sequencer
protected PresentsConnection.MessageHandler _handler
protected ClassLoader _loader
protected PresentsConnectionManager _pcmgr
| Constructor Detail |
|---|
public PresentsConnection()
| Method Detail |
|---|
public void init(ConnectionManager cmgr,
SocketChannel channel,
long createStamp)
throws IOException
PresentsConnectionManager as cmgr.
init in class Connectioncmgr - The connection manager with which this connection is associated.channel - The socket channel from which we'll be reading messages.createStamp - The time at which this connection was created.
IOExceptionpublic void setMessageHandler(PresentsConnection.MessageHandler handler)
public void clearMessageHandler()
public void setClassLoader(ClassLoader loader)
public void setTransmitDatagrams(boolean transmit)
public boolean getTransmitDatagrams()
public InetSocketAddress getDatagramAddress()
public DatagramChannel getDatagramChannel()
public void setDatagramSecret(String secret)
public void postMessage(Message msg)
public void handleDatagram(InetSocketAddress source,
DatagramChannel channel,
ByteBuffer buf,
long when)
public int handleEvent(long when)
NetEventHandler
protected ObjectInputStream getObjectInputStream()
protected ObjectInputStream createObjectInputStream(InputStream src)
protected void inheritStreams(PresentsConnection other)
protected ObjectOutputStream getObjectOutputStream(FramingOutputStream fout)
protected void setObjectOutputStream(ObjectOutputStream oout)
protected DatagramSequencer getDatagramSequencer()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||