basic client/server structure

This commit is contained in:
2025-02-27 12:52:12 +01:00
parent 2917535e05
commit fed666200c
9 changed files with 381 additions and 5 deletions

View File

@@ -0,0 +1,35 @@
package client;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketException;
import network.protocol.packets.LoginPacket;
import network.protocol.packets.SendChatMessagePacket;
public class Client {
private final ClientConnexion connexion;
public Client(InetSocketAddress serverAddress) throws SocketException {
this.connexion = new ClientConnexion(new DatagramSocket(), serverAddress);
login("Moi");
}
private void login(String pseudo) {
try {
this.connexion.sendPacket(new LoginPacket(pseudo));
} catch (IOException e) {
e.printStackTrace();
}
}
public void SendChatMessage(String message) {
try {
this.connexion.sendPacket(new SendChatMessagePacket(message));
} catch (IOException e) {
e.printStackTrace();
}
}
}