better network structure
Some checks failed
Linux arm64 / Build (push) Has been cancelled

This commit is contained in:
2025-01-23 22:24:23 +01:00
parent 5e99cd92df
commit bfe98a2cf0
22 changed files with 248 additions and 93 deletions

View File

@@ -4,6 +4,9 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import network.protocol.Packet;
import network.protocol.PacketVisitor;
public abstract class Connexion implements PacketVisitor {
final Socket socket;
@@ -17,8 +20,13 @@ public abstract class Connexion implements PacketVisitor {
this.connexionThread.start();
}
public void sendPacket(Packet packet) throws IOException {
objectOutputStream.writeObject(packet);
public void sendPacket(Packet packet) {
try {
objectOutputStream.writeObject(packet);
} catch (IOException e) {
System.err.println("Error while sending packet ! " + e.getLocalizedMessage());
close();
}
}
public void close() {