public class NetworkStateListener extends java.lang.Object implements StateListener
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTRIBUTE_KEY |
Constructor and Description |
---|
NetworkStateListener(EtherealHost host,
com.jme3.network.HostedConnection conn,
LocalZoneIndex zoneIndex,
IdIndex idIndex) |
NetworkStateListener(EtherealHost host,
com.jme3.network.HostedConnection conn,
ZoneGrid grid,
int zoneRadius) |
NetworkStateListener(EtherealHost host,
com.jme3.network.HostedConnection conn,
ZoneGrid grid,
com.simsilica.mathd.Vec3i zoneExtents) |
Modifier and Type | Method and Description |
---|---|
void |
beginFrame(long time) |
void |
beginFrameBlock() |
void |
endFrame(long time) |
void |
endFrameBlock() |
java.util.Set<java.lang.Long> |
getActiveIds()
Returns the set of all active IDs at this point in time.
|
ConnectionStats |
getConnectionStats() |
java.util.List<ZoneKey> |
getEnteredZones() |
java.util.List<ZoneKey> |
getExitedZones() |
int |
getMaxMessageSize() |
java.lang.Long |
getSelf() |
boolean |
hasChangedZones() |
void |
objectWarped(StateBlock.StateEntry entry)
Called after beginFrameBlock() but before beginFrame(), this lets
the listener know that an object had warped beyond any previous
zone ranges.
|
protected void |
postResponse(ClientStateMessage m)
Called when client state is received.
|
void |
setMaxMessageSize(int max)
Sets the desired maximum message size.
|
void |
setSelf(java.lang.Long self,
com.simsilica.mathd.Vec3d startingPosition) |
void |
stateChanged(StateBlock b) |
public static final java.lang.String ATTRIBUTE_KEY
public NetworkStateListener(EtherealHost host, com.jme3.network.HostedConnection conn, ZoneGrid grid, int zoneRadius)
public NetworkStateListener(EtherealHost host, com.jme3.network.HostedConnection conn, ZoneGrid grid, com.simsilica.mathd.Vec3i zoneExtents)
public NetworkStateListener(EtherealHost host, com.jme3.network.HostedConnection conn, LocalZoneIndex zoneIndex, IdIndex idIndex)
public void setSelf(java.lang.Long self, com.simsilica.mathd.Vec3d startingPosition)
public java.lang.Long getSelf()
public java.util.Set<java.lang.Long> getActiveIds()
public ConnectionStats getConnectionStats()
public void setMaxMessageSize(int max)
Set this to a really large value to avoid ever splitting a frame into multiple messages. This may make the actual transport of the message more likely to fail over disadvantaged comms and it may make the message take a little longer to reach the endpoint.
Notes on MTU and why this setting exists: for a particular connection there is a maximum message transmit unit size over which a UDP message will be split and reassembled. If any of the parts of that UDP message fail to arrive then the message is discarded completely. SimEthereal attempts to keep its own messages under a theoretical MTU size (by default 1500) in order to avoid this splitting. We trade calculation time and complexity for (hopefully) a higher likelihood that our messages make it there and in a timely manner (split UDP packets are only as fast as their slowest part, after all). Even if one of our self-split messages makes it then at least you get a partial frame update. If part of the UDP fails to make it then you get nothing.
public int getMaxMessageSize()
public boolean hasChangedZones()
hasChangedZones
in interface StateListener
public java.util.List<ZoneKey> getEnteredZones()
getEnteredZones
in interface StateListener
public java.util.List<ZoneKey> getExitedZones()
getExitedZones
in interface StateListener
protected void postResponse(ClientStateMessage m)
public void beginFrameBlock()
beginFrameBlock
in interface StateListener
public void endFrameBlock()
endFrameBlock
in interface StateListener
public void objectWarped(StateBlock.StateEntry entry)
StateListener
objectWarped
in interface StateListener
public void beginFrame(long time)
beginFrame
in interface StateListener
public void endFrame(long time)
endFrame
in interface StateListener
public void stateChanged(StateBlock b)
stateChanged
in interface StateListener