Much work on generalizing the notion of message "transport" and
allowing the use of annotations to customize transport for DObject fields and service/receiver methods. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5099 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -61,6 +61,7 @@ import com.threerings.presents.net.DownstreamMessage;
|
||||
import com.threerings.presents.net.LogoffRequest;
|
||||
import com.threerings.presents.net.PingRequest;
|
||||
import com.threerings.presents.net.PongResponse;
|
||||
import com.threerings.presents.net.Transport;
|
||||
import com.threerings.presents.net.UpstreamMessage;
|
||||
import com.threerings.presents.util.DatagramSequencer;
|
||||
|
||||
@@ -163,7 +164,7 @@ public class BlockingCommunicator extends Communicator
|
||||
public void postMessage (UpstreamMessage msg)
|
||||
{
|
||||
// post as datagram if hinted and possible
|
||||
if (msg.datagram && _datagramWriter != null) {
|
||||
if (!msg.getTransport().isReliable() && _datagramWriter != null) {
|
||||
_dataq.append(msg);
|
||||
} else {
|
||||
_msgq.append(msg);
|
||||
@@ -486,6 +487,7 @@ public class BlockingCommunicator extends Communicator
|
||||
if (_datagramChannel.read(_buf) <= 0) {
|
||||
throw new IOException("No datagram available to read.");
|
||||
}
|
||||
_buf.flip();
|
||||
|
||||
// decode through the sequencer
|
||||
try {
|
||||
@@ -493,7 +495,6 @@ public class BlockingCommunicator extends Communicator
|
||||
if (msg == null) {
|
||||
return null; // received out of order
|
||||
}
|
||||
msg.datagram = true;
|
||||
if (debugLogMessages()) {
|
||||
Log.info("DATAGRAM " + msg);
|
||||
}
|
||||
@@ -802,7 +803,7 @@ public class BlockingCommunicator extends Communicator
|
||||
_datagramChannel.connect(new InetSocketAddress(_client.getHostname(), port));
|
||||
for (int ii = 0; ii < DATAGRAM_ATTEMPTS_PER_PORT; ii++) {
|
||||
// send a ping datagram
|
||||
sendDatagram(new PingRequest());
|
||||
sendDatagram(new PingRequest(Transport.UNRELIABLE_UNORDERED));
|
||||
|
||||
// wait for a response
|
||||
int resp = _selector.select(DATAGRAM_RESPONSE_WAIT);
|
||||
|
||||
@@ -45,6 +45,8 @@ import com.threerings.presents.dobj.MessageEvent;
|
||||
import com.threerings.presents.dobj.ObjectAccessException;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
|
||||
import com.threerings.presents.net.Transport;
|
||||
|
||||
/**
|
||||
* Handles the client side management of the invocation services.
|
||||
*/
|
||||
@@ -195,6 +197,16 @@ public class InvocationDirector
|
||||
* invocation oid.
|
||||
*/
|
||||
public void sendRequest (int invOid, int invCode, int methodId, Object[] args)
|
||||
{
|
||||
sendRequest(invOid, invCode, methodId, args, Transport.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified invocation request be packaged up and sent to the supplied
|
||||
* invocation oid.
|
||||
*/
|
||||
public void sendRequest (
|
||||
int invOid, int invCode, int methodId, Object[] args, Transport transport)
|
||||
{
|
||||
if (_clobj == null) {
|
||||
Log.warning("Dropping invocation request on shutdown director [code=" + invCode +
|
||||
@@ -218,7 +230,8 @@ public class InvocationDirector
|
||||
}
|
||||
|
||||
// create an invocation request event
|
||||
InvocationRequestEvent event = new InvocationRequestEvent(invOid, invCode, methodId, args);
|
||||
InvocationRequestEvent event =
|
||||
new InvocationRequestEvent(invOid, invCode, methodId, args, transport);
|
||||
|
||||
// because invocation directors are used on the server, we set the source oid here so that
|
||||
// invocation requests are properly attributed to the right client object when created by
|
||||
|
||||
Reference in New Issue
Block a user