Skip to content

Commit

Permalink
Update Session.java
Browse files Browse the repository at this point in the history
  • Loading branch information
NycuRO authored Sep 6, 2016
1 parent ca4ac0b commit 81ea4ec
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/main/java/org/itxtech/synapseapi/network/synlib/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,15 @@ private void tickProcessor() {
private void tick() throws Exception {
if (this.update()) {
this.receivePacket();
int max = 5000;
while (max > 0 && this.sendPacket()){
max--;
}
int sendLen = 0;
do {
int len = this.sendPacket();
if (len > 0) {
sendLen += len;
} else {
break;
}
} while (sendLen < 65535);
}
}

Expand All @@ -101,13 +106,13 @@ private void receivePacket() throws Exception {
}
}

private boolean sendPacket() throws Exception {
private int sendPacket() throws Exception {
byte[] packet = this.server.readMainToThreadPacket();
if (packet != null && packet.length > 0) {
this.writePacket(packet);
return true;
return packet.length;
}
return false;
return -1;
}

public String getHash() {
Expand Down

0 comments on commit 81ea4ec

Please sign in to comment.