established connection between Client and Serveur, setting up basic interactions
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user