|
|
@ -5,6 +5,8 @@ using System.Net.Sockets;
|
|
|
|
|
|
|
|
|
|
|
|
class Program
|
|
|
|
class Program
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int playerCount = 0;
|
|
|
|
static void Main(string[] args)
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine("Welcome to LeapHit Multiplayer - Server");
|
|
|
|
Console.WriteLine("Welcome to LeapHit Multiplayer - Server");
|
|
|
@ -18,12 +20,22 @@ class Program
|
|
|
|
Console.WriteLine("Server started, waiting for clients to connect...");
|
|
|
|
Console.WriteLine("Server started, waiting for clients to connect...");
|
|
|
|
Console.WriteLine(endPoint.Address.ToString());
|
|
|
|
Console.WriteLine(endPoint.Address.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
while (playerCount < 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IPEndPoint clientEndPoint = new IPEndPoint(IPAddress.Any, 0);
|
|
|
|
IPEndPoint clientEndPoint = new IPEndPoint(IPAddress.Any, 0);
|
|
|
|
byte[] data = server.Receive(ref clientEndPoint);
|
|
|
|
byte[] data = server.Receive(ref clientEndPoint);
|
|
|
|
string dataReceived = System.Text.Encoding.ASCII.GetString(data);
|
|
|
|
string dataReceived = System.Text.Encoding.ASCII.GetString(data);
|
|
|
|
Console.WriteLine("Data received from client: " + dataReceived + " from " + clientEndPoint.ToString());
|
|
|
|
Console.WriteLine("Data received from client: " + dataReceived + " from " + clientEndPoint.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
playerCount++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (playerCount == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine("Deux joueurs connectés, le jeu va commencer...");
|
|
|
|
|
|
|
|
// On va mettre le code du pour demarrer le match ici
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
server.Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|