|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.jme3.network.base.KernelAdapter
public class KernelAdapter
Wraps a single Kernel and forwards new messages to the supplied message dispatcher and new endpoint events to the connection dispatcher. This is used by DefaultServer to manage its kernel objects.
This adapter assumes a simple protocol where two bytes define a (short) object size with the object data to follow. Note: this limits the size of serialized objects to 32676 bytes... even though, for example, datagram packets can hold twice that. :P
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
KernelAdapter(DefaultServer server,
Kernel kernel,
MessageListener<HostedConnection> messageDispatcher,
boolean reliable)
|
Method Summary | |
---|---|
void |
broadcast(Filter<? super Endpoint> filter,
java.nio.ByteBuffer data,
boolean reliable,
boolean copy)
|
void |
close()
|
protected void |
connectionClosed(Endpoint p)
|
protected void |
createAndDispatch(EndpointEvent event)
|
protected void |
createAndDispatch(Envelope env)
|
protected void |
dispatch(Endpoint p,
Message m)
Note on threading for those writing their own server or adapter implementations. |
protected void |
flushEvents()
|
protected HostedConnection |
getConnection(Endpoint p)
|
Kernel |
getKernel()
|
protected MessageProtocol |
getMessageBuffer(Endpoint p)
|
void |
initialize()
|
protected void |
reportError(Endpoint p,
java.lang.Object context,
java.lang.Exception e)
|
void |
run()
|
Methods inherited from class java.lang.Thread |
---|
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, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public KernelAdapter(DefaultServer server, Kernel kernel, MessageListener<HostedConnection> messageDispatcher, boolean reliable)
Method Detail |
---|
public Kernel getKernel()
public void initialize()
public void broadcast(Filter<? super Endpoint> filter, java.nio.ByteBuffer data, boolean reliable, boolean copy)
public void close() throws java.lang.InterruptedException
java.lang.InterruptedException
protected void reportError(Endpoint p, java.lang.Object context, java.lang.Exception e)
protected HostedConnection getConnection(Endpoint p)
protected void connectionClosed(Endpoint p)
protected void dispatch(Endpoint p, Message m)
The issue with the messages is that if a an implementation is using a general thread pool then it would be possible for a naive implementation to have one thread grab an Envelope from connection 1's and another grab the next Envelope. Since an Envelope may contain several messages, delivering the second thread's messages before or during the first's would be really confusing and hard to code for in user code.
And that's why this note is here. DefaultServer does a rudimentary per-connection locking but it couldn't possibly guard against out of order Envelope processing.
protected MessageProtocol getMessageBuffer(Endpoint p)
protected void createAndDispatch(Envelope env)
protected void createAndDispatch(EndpointEvent event)
protected void flushEvents()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |