established connection between Client and Serveur, setting up basic interactions

This commit is contained in:
Clément
2025-02-27 22:04:11 +01:00
parent fed666200c
commit db9b41b190
8 changed files with 160 additions and 21 deletions

View File

@@ -5,13 +5,21 @@ import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketException;
import network.protocol.packets.LoginPacket;
import network.protocol.packets.SendChatMessagePacket;
import network.protocol.packets.*;
public class Client {
private final ClientConnexion connexion;
public static void main(String[] args) {
try {
Client client = new Client(new InetSocketAddress("localhost", 6665));
client.SendChatMessage("Hello");
} catch (SocketException e) {
e.printStackTrace();
}
}
public Client(InetSocketAddress serverAddress) throws SocketException {
this.connexion = new ClientConnexion(new DatagramSocket(), serverAddress);
login("Moi");
@@ -32,4 +40,20 @@ public class Client {
e.printStackTrace();
}
}
public void SendCreateRoom(String roomName) {
try {
this.connexion.sendPacket(new CreateRoomPacket(roomName));
} catch (Exception e) {
e.printStackTrace();
}
}
public void RequestRoomList() {
try {
this.connexion.sendPacket(new RequestRoomListPacket());
} catch (Exception e) {
e.printStackTrace();
}
}
}