diff --git a/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java b/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java
index 751a33e5a..171eb656e 100644
--- a/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java
+++ b/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java
@@ -66,6 +66,16 @@ public abstract class ConnectionManager extends LoopingThread
_onExit = onExit;
}
+ /**
+ * Set the largest number of bytes we'll send in a message.
+ * Messages larger than this will log, refuse to send, and then things go badly for that client.
+ * We don't presently handle this well, we may as well disconnect the player at that point.
+ */
+ public void setMaximumMessageSize (int maximumMessageSize)
+ {
+ _maxMsgSize = maximumMessageSize;
+ }
+
/**
* Returns our current runtime statistics. Note: don't call this method too
* frequently as it is synchronized and will contend with the network I/O thread.
@@ -339,7 +349,7 @@ public abstract class ConnectionManager extends LoopingThread
}
// sanity check the message size
- if (data.length > 1024 * 1024) {
+ if (data.length > _maxMsgSize) {
log.warning("Refusing to write very large message", "conn", conn, "size", data.length);
return true;
}
@@ -606,6 +616,9 @@ public abstract class ConnectionManager extends LoopingThread
/** Our current runtime stats. */
protected ConMgrStats _stats = new ConMgrStats();
+ /** The maximum message size we'll send. */
+ protected int _maxMsgSize = 1024 * 1024;
+
/** Used to periodically report connection manager activity when in debug mode. */
protected long _lastDebugStamp;