Merge branch 'master' into crypto_step1
# Conflicts: # src/dorkbox/network/connection/RegistrationWrapper.java
This commit is contained in:
commit
4efa01b8fb
|
@ -47,6 +47,8 @@ import io.netty.channel.Channel;
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
class RegistrationWrapper {
|
class RegistrationWrapper {
|
||||||
|
private static final int CLASS_REGISTRATION_VALIDATION_FRAGMENT_SIZE = 400;
|
||||||
|
|
||||||
public
|
public
|
||||||
enum STATE { ERROR, WAIT, CONTINUE }
|
enum STATE { ERROR, WAIT, CONTINUE }
|
||||||
|
|
||||||
|
@ -327,17 +329,16 @@ class RegistrationWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public
|
public
|
||||||
boolean initClassRegistration(final Channel channel, final Registration registration) {
|
boolean initClassRegistration(final Channel channel, final Registration registration) {
|
||||||
byte[] details = this.endPoint.getSerialization().getKryoRegistrationDetails();
|
byte[] details = this.endPoint.getSerialization().getKryoRegistrationDetails();
|
||||||
|
|
||||||
int length = details.length;
|
int length = details.length;
|
||||||
if (length > 480) {
|
if (length > CLASS_REGISTRATION_VALIDATION_FRAGMENT_SIZE) {
|
||||||
// it is too large to send in a single packet
|
// it is too large to send in a single packet
|
||||||
|
|
||||||
// child arrays have index 0 also as their 'index' and 1 is the total number of fragments
|
// child arrays have index 0 also as their 'index' and 1 is the total number of fragments
|
||||||
byte[][] fragments = divideArray(details, 400);
|
byte[][] fragments = divideArray(details, CLASS_REGISTRATION_VALIDATION_FRAGMENT_SIZE);
|
||||||
if (fragments == null) {
|
if (fragments == null) {
|
||||||
logger.error("Too many classes have been registered for Serialization. Please report this issue");
|
logger.error("Too many classes have been registered for Serialization. Please report this issue");
|
||||||
|
|
||||||
|
@ -386,19 +387,19 @@ class RegistrationWrapper {
|
||||||
byte[] fragment = registration.payload;
|
byte[] fragment = registration.payload;
|
||||||
|
|
||||||
// this means that the registrations are FRAGMENTED!
|
// this means that the registrations are FRAGMENTED!
|
||||||
// max size of ALL fragments is 480 * 127
|
// max size of ALL fragments is xxx * 127
|
||||||
if (metaChannel.fragmentedRegistrationDetails == null) {
|
if (metaChannel.fragmentedRegistrationDetails == null) {
|
||||||
metaChannel.remainingFragments = fragment[1];
|
metaChannel.remainingFragments = fragment[1];
|
||||||
metaChannel.fragmentedRegistrationDetails = new byte[480 * fragment[1]];
|
metaChannel.fragmentedRegistrationDetails = new byte[CLASS_REGISTRATION_VALIDATION_FRAGMENT_SIZE * fragment[1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
System.arraycopy(fragment, 2, metaChannel.fragmentedRegistrationDetails, fragment[0] * 480, fragment.length - 2);
|
System.arraycopy(fragment, 2, metaChannel.fragmentedRegistrationDetails, fragment[0] * CLASS_REGISTRATION_VALIDATION_FRAGMENT_SIZE, fragment.length - 2);
|
||||||
metaChannel.remainingFragments--;
|
metaChannel.remainingFragments--;
|
||||||
|
|
||||||
|
|
||||||
if (fragment[0] + 1 == fragment[1]) {
|
if (fragment[0] + 1 == fragment[1]) {
|
||||||
// this is the last fragment in the in byte array (but NOT necessarily the last fragment to arrive)
|
// this is the last fragment in the in byte array (but NOT necessarily the last fragment to arrive)
|
||||||
int correctSize = (480 * (fragment[1] - 1)) + (fragment.length - 2);
|
int correctSize = (CLASS_REGISTRATION_VALIDATION_FRAGMENT_SIZE * (fragment[1] - 1)) + (fragment.length - 2);
|
||||||
byte[] correctlySized = new byte[correctSize];
|
byte[] correctlySized = new byte[correctSize];
|
||||||
System.arraycopy(metaChannel.fragmentedRegistrationDetails, 0, correctlySized, 0, correctSize);
|
System.arraycopy(metaChannel.fragmentedRegistrationDetails, 0, correctlySized, 0, correctSize);
|
||||||
metaChannel.fragmentedRegistrationDetails = correctlySized;
|
metaChannel.fragmentedRegistrationDetails = correctlySized;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user