Added an extra step to the datagram negotation process. Before
the server starts sending datagrams willy-nilly, it must wait for a (reliable) go-ahead from the client. Otherwise, it's possible that the server may be successfully receiving datagrams but not sending them. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5792 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -121,6 +121,22 @@ public class Connection implements NetEventHandler
|
||||
return (_channel == null) ? null : _channel.socket().getInetAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether we should transmit datagrams.
|
||||
*/
|
||||
public void setTransmitDatagrams (boolean transmit)
|
||||
{
|
||||
_transmitDatagrams = transmit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether we should transmit datagrams.
|
||||
*/
|
||||
public boolean getTransmitDatagrams ()
|
||||
{
|
||||
return _transmitDatagrams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address to which datagrams should be sent or null if no datagram address has
|
||||
* been established.
|
||||
@@ -435,6 +451,7 @@ public class Connection implements NetEventHandler
|
||||
|
||||
protected InetSocketAddress _datagramAddress;
|
||||
protected byte[] _datagramSecret;
|
||||
protected boolean _transmitDatagrams;
|
||||
|
||||
protected MessageDigest _digest;
|
||||
protected DatagramSequencer _sequencer;
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.threerings.presents.annotation.AuthInvoker;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.ConMgrStats;
|
||||
import com.threerings.presents.net.Message;
|
||||
import com.threerings.presents.net.PongResponse;
|
||||
import com.threerings.presents.server.Authenticator;
|
||||
import com.threerings.presents.server.ChainedAuthenticator;
|
||||
import com.threerings.presents.server.ClientManager;
|
||||
@@ -902,9 +903,11 @@ public class ConnectionManager extends LoopingThread
|
||||
}
|
||||
|
||||
try {
|
||||
// send it as a datagram if hinted and possible
|
||||
if (!msg.getTransport().isReliable() && conn.getDatagramAddress() != null &&
|
||||
postDatagram(conn, msg)) {
|
||||
// send it as a datagram if hinted and possible (pongs must be sent as part of the
|
||||
// negotation process)
|
||||
if (!msg.getTransport().isReliable() &&
|
||||
(conn.getTransmitDatagrams() || msg instanceof PongResponse) &&
|
||||
postDatagram(conn, msg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user