Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Showing
with 41 additions and 10 deletions
No preview for this file type
File added
File added
File added
File added
......@@ -14,11 +14,22 @@ namespace TronClient
public byte frequence; // Temps du tour de jeu (en dixieme de s)
Socket clientSocket;
IPEndPoint serverEP;
// constructeur : IP/Port du serveur
public Client(String myServerIP, int myServerPort)
{
// TODO : Creation de la socket d'écoute TCP
clientSocket = new Socket(
AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
// Liaison de la socket au point de communication
clientSocket.Bind(new IPEndPoint(IPAddress.Any, 0));
// Creation du EndPoint serveur
serverEP = new IPEndPoint(IPAddress.Parse(myServerIP), myServerPort);
}
......@@ -28,14 +39,17 @@ namespace TronClient
System.Console.WriteLine("Init");
// TODO Connexion au serveur
clientSocket.Connect(serverEP);
// TODO Réception des paramètres
byte[] buffer = new byte[4];
clientSocket.Receive(buffer, buffer.Length, SocketFlags.None);
// TODO Initialisation de la fréquence : frequence = <frequence>
frequence = 1;
frequence = buffer[3];
// TODO Initialisation du moteur : myTron = new Tron(byte <taille terrain>, byte <nombre de joueurs>, byte <numéro du joueur>);
myTron = new Tron.Tron(60, 2, 0);
myTron = new Tron.Tron(buffer[0], buffer[1], buffer[2]);
// Retourne le moteur
return myTron;
......@@ -47,8 +61,12 @@ namespace TronClient
System.Console.WriteLine("Routine");
// TODO Envoie de sa direction : myTron.getDirection()
// TOSO Reception de toutes les directions : myTron.setDirections(byte[] < toutes les directions>);
byte[] buffer = new byte[] { myTron.getDirection() };
clientSocket.Send(buffer, 0, buffer.Length, SocketFlags.None);
// TODO Reception de toutes les directions : myTron.setDirections(byte[] < toutes les directions>);
buffer = new byte[myTron.getNJoueurs()];
clientSocket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
myTron.setDirections(buffer);
}
// Appelé à la fin de la partie
......@@ -56,7 +74,9 @@ namespace TronClient
{
System.Console.WriteLine("Conclusion");
// fermeture socket
// Fermeture socket
Console.WriteLine("Fermeture Socket...");
clientSocket.Close();
}
......
......@@ -49,7 +49,7 @@
this.textBoxIP.Name = "textBoxIP";
this.textBoxIP.Size = new System.Drawing.Size(123, 20);
this.textBoxIP.TabIndex = 1;
this.textBoxIP.Text = "127.0.0.1";
this.textBoxIP.Text = "130.79.81.69";
//
// textBoxPort
//
......@@ -57,7 +57,7 @@
this.textBoxPort.Name = "textBoxPort";
this.textBoxPort.Size = new System.Drawing.Size(50, 20);
this.textBoxPort.TabIndex = 2;
this.textBoxPort.Text = "8000";
this.textBoxPort.Text = "11111";
//
// FormLobby
//
......
......@@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
File added
File added
File added
File added
d114d63f213d8487ba93b3e80c16396e23112287
U:\Bureau\S32\Tron\TronClient\TronClient\bin\Debug\TronClient.exe
U:\Bureau\S32\Tron\TronClient\TronClient\bin\Debug\TronClient.pdb
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.csprojAssemblyReference.cache
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.FormLobby.resources
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.FormTron.resources
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.Properties.Resources.resources
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.csproj.GenerateResource.cache
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.csproj.CoreCompileInputs.cache
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.exe
U:\Bureau\S32\Tron\TronClient\TronClient\obj\Debug\TronClient.pdb