mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-12 08:41:00 -05:00
Ignore reading in closing socket
This commit is contained in:
parent
e2f325a3f1
commit
9f7e7302a5
1 changed files with 2 additions and 12 deletions
|
@ -56,11 +56,6 @@ public abstract class StandardConnection extends BaseConnection {
|
||||||
*/
|
*/
|
||||||
private Queue<Packet> packets = new ConcurrentLinkedQueue<Packet>();
|
private Queue<Packet> packets = new ConcurrentLinkedQueue<Packet>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the connection is reading.
|
|
||||||
*/
|
|
||||||
private boolean reading = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the connection is writing.
|
* Whether the connection is writing.
|
||||||
*/
|
*/
|
||||||
|
@ -170,7 +165,6 @@ public abstract class StandardConnection extends BaseConnection {
|
||||||
public void run() {
|
public void run() {
|
||||||
while(isConnected()) {
|
while(isConnected()) {
|
||||||
try {
|
try {
|
||||||
reading = true;
|
|
||||||
int opcode = input.readUnsignedByte();
|
int opcode = input.readUnsignedByte();
|
||||||
if(opcode < 0) {
|
if(opcode < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -190,8 +184,6 @@ public abstract class StandardConnection extends BaseConnection {
|
||||||
} else if(StandardConnection.this instanceof ServerConnection) {
|
} else if(StandardConnection.this instanceof ServerConnection) {
|
||||||
packet.handleServer((ServerConnection) StandardConnection.this);
|
packet.handleServer((ServerConnection) StandardConnection.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
reading = false;
|
|
||||||
} catch(EOFException e) {
|
} catch(EOFException e) {
|
||||||
disconnect("End of Stream");
|
disconnect("End of Stream");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -204,8 +196,6 @@ public abstract class StandardConnection extends BaseConnection {
|
||||||
Thread.sleep(2);
|
Thread.sleep(2);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
reading = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,12 +236,12 @@ public abstract class StandardConnection extends BaseConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thread that waits for the connection to finish before closing it.
|
* A thread that waits for the connection to finish writing before closing it.
|
||||||
*/
|
*/
|
||||||
private class CloseThread extends Thread {
|
private class CloseThread extends Thread {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while(reading || writing) {
|
while(writing) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(2);
|
Thread.sleep(2);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
Loading…
Reference in a new issue