network structure
Some checks failed
Linux arm64 / Build (push) Failing after 5m1s

This commit is contained in:
2025-01-23 18:59:11 +01:00
parent b05351bc20
commit 5e99cd92df
21 changed files with 429 additions and 36 deletions

View File

@@ -0,0 +1,27 @@
package network;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
public abstract class Connexion implements PacketVisitor {
final Socket socket;
private final ObjectOutputStream objectOutputStream;
private final ConnexionThread connexionThread;
public Connexion(Socket socket) throws IOException {
this.socket = socket;
this.objectOutputStream = new ObjectOutputStream(this.socket.getOutputStream());
this.connexionThread = new ConnexionThread(this);
this.connexionThread.start();
}
public void sendPacket(Packet packet) throws IOException {
objectOutputStream.writeObject(packet);
}
public void close() {
this.connexionThread.cancel();
}
}