modif architecture compil&test sans serveur ok
This commit is contained in:
parent
f88809a50a
commit
9db1e53dd7
|
@ -37,7 +37,7 @@ namespace go01
|
||||||
|
|
||||||
var startTimeSpan = TimeSpan.Zero;
|
var startTimeSpan = TimeSpan.Zero;
|
||||||
var periodTimeSpan = TimeSpan.FromSeconds(5);
|
var periodTimeSpan = TimeSpan.FromSeconds(5);
|
||||||
socketPlateauBase.ConfigGo_S config = new socketPlateauBase.ConfigGo_S(tbUid.Text, tbPartName.Text, "", tbNomJoeur.Text, int.Parse(tbTaille.Text), int.Parse(tbPionaAligner.Text), IPAddress.Parse(tbIp.Text), int.Parse(tbPort.Text));
|
Goban.ConfigGo_S config = new Goban.ConfigGo_S(tbPartName.Text, "", tbNomJoeur.Text, int.Parse(tbTaille.Text), int.Parse(tbPionaAligner.Text), IPAddress.Parse(tbIp.Text), int.Parse(tbPort.Text));
|
||||||
serveur = new socketPlateauSRV(config, null, new socketPlateauSRV.OnJoinServ(ConnectionEtablie));
|
serveur = new socketPlateauSRV(config, null, new socketPlateauSRV.OnJoinServ(ConnectionEtablie));
|
||||||
serveur.AttenteJoueur();
|
serveur.AttenteJoueur();
|
||||||
|
|
||||||
|
@ -45,10 +45,10 @@ namespace go01
|
||||||
}
|
}
|
||||||
private void ConnectionEtablie(object o, socketPlateauServJoinArgs e)
|
private void ConnectionEtablie(object o, socketPlateauServJoinArgs e)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{e.ConfigGo.NomJoeurClient} vs {e.ConfigGo.NomJoeurServeur}");
|
Console.WriteLine($"{e.ConfigGo.NomJoeurBlanc} vs {e.ConfigGo.NomJoeurNoir}");
|
||||||
serveur.senCmd(new socketPlateauBase.CommandeSocket_S(socketPlateauBase.commande_E.Join, new socketPlateauServACKArgs(true)));
|
serveur.senCmd(new socketPlateauBase.CommandeSocket_S(socketPlateauBase.commande_E.Join, new socketPlateauServACKArgs(true)));
|
||||||
Console.WriteLine("CONNETION ETABLEIE");
|
Console.WriteLine("CONNETION ETABLEIE");
|
||||||
Plateau p = new Plateau(e.ConfigGo.Taille, e.ConfigGo.PionAligner, e.ConfigGo.NomJoeurServeur, e.ConfigGo.NomJoeurClient);
|
Plateau p = new Plateau(e.ConfigGo.taille, e.ConfigGo.PionAligner, e.ConfigGo.NomJoeurNoir, e.ConfigGo.NomJoeurBlanc);
|
||||||
//this.Hide();
|
//this.Hide();
|
||||||
p.ShowDialog();
|
p.ShowDialog();
|
||||||
//this.Close();
|
//this.Close();
|
||||||
|
|
149
go01/Goban.cs
149
go01/Goban.cs
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -12,22 +13,16 @@ namespace go01
|
||||||
{
|
{
|
||||||
public class Goban
|
public class Goban
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PictureBox Conteneur;
|
public PictureBox Conteneur;
|
||||||
int nombreDePionAAligne;
|
|
||||||
int ptBlanc = 0, ptNoir = 0;
|
int ptBlanc = 0, ptNoir = 0;
|
||||||
public Plateau Fenetre;
|
public Plateau Fenetre;
|
||||||
bool win = false;
|
bool win = false;
|
||||||
public int dim;
|
|
||||||
Label LabelPlayerTurn;
|
Label LabelPlayerTurn;
|
||||||
public string PlayerTurn { get { return this.LabelPlayerTurn.Text; } }
|
public string PlayerTurn { get { return this.LabelPlayerTurn.Text; } }
|
||||||
string playerWName, playerBName;
|
string playerWName { get => cfg.NomJoeurBlanc; }
|
||||||
|
string playerBName{ get => cfg.NomJoeurNoir; }
|
||||||
List<PictureBox> pboxList = new List<PictureBox>();
|
List<PictureBox> pboxList = new List<PictureBox>();
|
||||||
public enum Occupant_E { Vide, Blanc, Noir, LAST }
|
|
||||||
public enum Joueur_E { Blanc, Noir, LAST }
|
|
||||||
|
|
||||||
Joueur_E tour;
|
Joueur_E tour;
|
||||||
Joueur_E Tour
|
Joueur_E Tour
|
||||||
|
@ -52,8 +47,11 @@ namespace go01
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Occupant_E[,] tableauOccupation;
|
Occupant_E[,] tableauOccupation;
|
||||||
|
ConfigGo_S cfg;
|
||||||
|
|
||||||
|
#region struct&enum
|
||||||
|
public enum Occupant_E { Vide, Blanc, Noir, LAST }
|
||||||
|
public enum Joueur_E { Blanc, Noir, LAST }
|
||||||
[Flags]
|
[Flags]
|
||||||
enum Deplacement_E
|
enum Deplacement_E
|
||||||
{
|
{
|
||||||
|
@ -69,20 +67,18 @@ namespace go01
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct sauvegarde_S
|
public struct sauvegarde_S
|
||||||
{
|
{
|
||||||
public string nomBlanc, nomNoir;
|
public ConfigGo_S cfg;
|
||||||
public int ptBlanc, ptNoir;
|
public int ptBlanc, ptNoir;
|
||||||
public int dimGoban, nbAlignementToWin;
|
|
||||||
public bool win;
|
public bool win;
|
||||||
public Goban.Occupant_E[,] tableauOccupation;
|
public Goban.Occupant_E[,] tableauOccupation;
|
||||||
public Goban.Joueur_E tour;
|
public Goban.Joueur_E tour;
|
||||||
public sauvegarde_S(string nomBlanc, string nomNoir, int pointBlanc, int pointNoir, int nbAlignementToWin, int dimGoban, Goban.Occupant_E[,] tableauOccupation, Goban.Joueur_E tour, bool win)
|
public sauvegarde_S(int pointBlanc, int pointNoir, Goban.Occupant_E[,] tableauOccupation, Goban.Joueur_E tour, bool win, ConfigGo_S cfg)
|
||||||
{
|
{
|
||||||
this.nomBlanc = nomBlanc; this.nomNoir = nomNoir;
|
|
||||||
this.ptBlanc = pointBlanc; this.ptNoir = pointNoir;
|
this.ptBlanc = pointBlanc; this.ptNoir = pointNoir;
|
||||||
this.dimGoban = dimGoban; this.nbAlignementToWin = nbAlignementToWin;
|
|
||||||
this.win = win;
|
this.win = win;
|
||||||
this.tableauOccupation = tableauOccupation;
|
this.tableauOccupation = tableauOccupation;
|
||||||
this.tour = tour;
|
this.tour = tour;
|
||||||
|
this.cfg = cfg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct carrefour_S
|
struct carrefour_S
|
||||||
|
@ -95,16 +91,48 @@ namespace go01
|
||||||
SensDeDeplacment = sens;
|
SensDeDeplacment = sens;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[Serializable]
|
||||||
|
public struct ConfigGo_S
|
||||||
|
{
|
||||||
|
public readonly string Uid;
|
||||||
|
private string partName;
|
||||||
|
public string PartName { get { return partName; } }
|
||||||
|
public string NomJoeurBlanc;
|
||||||
|
public string NomJoeurNoir;
|
||||||
|
public readonly int taille;
|
||||||
|
public readonly int pionaAligner;
|
||||||
|
public int PionAligner { get { return pionaAligner; } }
|
||||||
|
public readonly IPAddress IpServeur;
|
||||||
|
public readonly int port;
|
||||||
|
|
||||||
|
public ConfigGo_S(string PartName, string NomJoeurBlanc, string NomJoeurNoir, int Taille, int PionaAligner, IPAddress ipServeur=null, int port=-1)
|
||||||
|
{
|
||||||
|
this.Uid = Guid.NewGuid().ToString(); ;
|
||||||
|
this.partName = PartName;
|
||||||
|
this.NomJoeurBlanc = NomJoeurBlanc;
|
||||||
|
this.NomJoeurNoir = NomJoeurNoir;
|
||||||
|
this.taille = Taille;
|
||||||
|
this.pionaAligner = PionaAligner;
|
||||||
|
this.IpServeur = ipServeur;
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return partName;
|
||||||
|
}
|
||||||
|
public static implicit operator string(ConfigGo_S part)
|
||||||
|
{
|
||||||
|
return part.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Goban(Plateau fenetre, PictureBox conteneur, sauvegarde_S s)
|
public Goban(Plateau fenetre, PictureBox conteneur, sauvegarde_S s)
|
||||||
{
|
{
|
||||||
tableauOccupation = s.tableauOccupation;
|
tableauOccupation = s.tableauOccupation;
|
||||||
playerBName = s.nomNoir;
|
this.cfg = s.cfg;
|
||||||
playerWName = s.nomBlanc;
|
|
||||||
nombreDePionAAligne = s.nbAlignementToWin;
|
|
||||||
dim = s.dimGoban;
|
|
||||||
|
|
||||||
this.Conteneur = conteneur;
|
this.Conteneur = conteneur;
|
||||||
this.Fenetre = fenetre;
|
this.Fenetre = fenetre;
|
||||||
|
@ -115,29 +143,22 @@ namespace go01
|
||||||
GenerationPlateau(false);
|
GenerationPlateau(false);
|
||||||
//redrawAllpb();
|
//redrawAllpb();
|
||||||
}
|
}
|
||||||
public Goban(Plateau fenetre, PictureBox conteneur, socketPlateauBase.ConfigGo_S cfg) : this(fenetre, conteneur, cfg.Taille, cfg.PionAligner, cfg.NomJoeurClient, cfg.NomJoeurServeur)
|
public Goban(Plateau fenetre, PictureBox conteneur, ConfigGo_S cfg)
|
||||||
{}
|
|
||||||
public Goban(Plateau fenetre, PictureBox conteneur, int dim, int nbPionAlignn, string playerW, string playerB)
|
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
nombreDePionAAligne = nbPionAlignn;
|
|
||||||
this.Conteneur = conteneur;
|
this.Conteneur = conteneur;
|
||||||
this.dim = dim;
|
|
||||||
this.Fenetre = fenetre;
|
this.Fenetre = fenetre;
|
||||||
|
this.cfg = cfg;
|
||||||
playerWName = playerW;
|
fenetre.lblBlanc = playerWName + ":0";
|
||||||
playerBName = playerB;
|
fenetre.lblNoir = playerBName + ":0";
|
||||||
|
|
||||||
fenetre.lblBlanc = playerB + ":0";
|
|
||||||
fenetre.lblNoir = playerW + ":0";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Tour = Joueur_E.Noir;
|
Tour = Joueur_E.Noir;
|
||||||
|
|
||||||
//gen des tab
|
//gen des tab
|
||||||
tableauOccupation = new Occupant_E[dim, dim];
|
tableauOccupation = new Occupant_E[cfg.taille, cfg.taille];
|
||||||
GenerationPlateau();
|
GenerationPlateau();
|
||||||
|
}
|
||||||
|
public Goban(Plateau fenetre, PictureBox conteneur, int dim, int nbPionAlignn, string playerW, string playerB) : this(fenetre,conteneur, new ConfigGo_S("",playerW,playerB,dim,nbPionAlignn))
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public void PaintPb(object sender, PaintEventArgs e)
|
public void PaintPb(object sender, PaintEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -191,7 +212,7 @@ namespace go01
|
||||||
}
|
}
|
||||||
private int[] GetXY(int i)
|
private int[] GetXY(int i)
|
||||||
{
|
{
|
||||||
return new int[2] { i % dim, i / dim };
|
return new int[2] { i % cfg.taille, i / cfg.taille };
|
||||||
}
|
}
|
||||||
private int[] GetXYStr(string s)
|
private int[] GetXYStr(string s)
|
||||||
{
|
{
|
||||||
|
@ -200,11 +221,11 @@ namespace go01
|
||||||
}
|
}
|
||||||
private int GetX(int i)
|
private int GetX(int i)
|
||||||
{
|
{
|
||||||
return i % dim;
|
return i % cfg.taille;
|
||||||
}
|
}
|
||||||
private int GetY(int i)
|
private int GetY(int i)
|
||||||
{
|
{
|
||||||
return i / dim;
|
return i / cfg.taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RechercheTeritoir(int x, int y)
|
bool RechercheTeritoir(int x, int y)
|
||||||
|
@ -213,7 +234,7 @@ namespace go01
|
||||||
|
|
||||||
int pionAligneDsRecherche = 1;
|
int pionAligneDsRecherche = 1;
|
||||||
|
|
||||||
int[,] tmpParcour = new int[dim, dim];
|
int[,] tmpParcour = new int[cfg.taille, cfg.taille];
|
||||||
tmpParcour[origine.X, origine.Y] = 1;
|
tmpParcour[origine.X, origine.Y] = 1;
|
||||||
List<carrefour_S>pointsSuivant = RecherchePointsSuivant(origine,(Deplacement_E)0xff);//Recherche les point autour du pion
|
List<carrefour_S>pointsSuivant = RecherchePointsSuivant(origine,(Deplacement_E)0xff);//Recherche les point autour du pion
|
||||||
if (pointsSuivant.Count == 0)
|
if (pointsSuivant.Count == 0)
|
||||||
|
@ -231,7 +252,7 @@ namespace go01
|
||||||
printTab(tmpParcour);
|
printTab(tmpParcour);
|
||||||
}
|
}
|
||||||
Console.WriteLine(pionAligneDsRecherche);
|
Console.WriteLine(pionAligneDsRecherche);
|
||||||
if (pionAligneDsRecherche >= nombreDePionAAligne*(Math.Ceiling((double)pionAligneDsRecherche/(double)nombreDePionAAligne)))
|
if (pionAligneDsRecherche >= cfg.pionaAligner*(Math.Ceiling((double)pionAligneDsRecherche/(double)cfg.pionaAligner)))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -248,23 +269,23 @@ namespace go01
|
||||||
{
|
{
|
||||||
PointsTrouver.Add(new carrefour_S(new Point(p.X,p.Y-1),Deplacement_E.S));
|
PointsTrouver.Add(new carrefour_S(new Point(p.X,p.Y-1),Deplacement_E.S));
|
||||||
}
|
}
|
||||||
if (p.Y - 1 >= 0 && p.X+1 < dim && tableauOccupation[p.X+1,p.Y-1] == occupant && (deplacement & Deplacement_E.SD) == Deplacement_E.SD)
|
if (p.Y - 1 >= 0 && p.X+1 < cfg.taille && tableauOccupation[p.X+1,p.Y-1] == occupant && (deplacement & Deplacement_E.SD) == Deplacement_E.SD)
|
||||||
{
|
{
|
||||||
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y-1),Deplacement_E.SD));
|
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y-1),Deplacement_E.SD));
|
||||||
}
|
}
|
||||||
if (p.X + 1 < dim && tableauOccupation[p.X+1,p.Y] == occupant && (deplacement & Deplacement_E.D) == Deplacement_E.D)
|
if (p.X + 1 < cfg.taille && tableauOccupation[p.X+1,p.Y] == occupant && (deplacement & Deplacement_E.D) == Deplacement_E.D)
|
||||||
{
|
{
|
||||||
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y),Deplacement_E.D));
|
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y),Deplacement_E.D));
|
||||||
}
|
}
|
||||||
if (p.X + 1 < dim && p.Y+1<dim && tableauOccupation[p.X+1,p.Y+1] == occupant && (deplacement & Deplacement_E.ID) == Deplacement_E.ID)
|
if (p.X + 1 < cfg.taille && p.Y+1<cfg.taille && tableauOccupation[p.X+1,p.Y+1] == occupant && (deplacement & Deplacement_E.ID) == Deplacement_E.ID)
|
||||||
{
|
{
|
||||||
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y+1),Deplacement_E.ID));
|
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y+1),Deplacement_E.ID));
|
||||||
}
|
}
|
||||||
if (p.Y + 1 < dim && tableauOccupation[p.X,p.Y+1] == occupant && (deplacement & Deplacement_E.I) == Deplacement_E.I)
|
if (p.Y + 1 < cfg.taille && tableauOccupation[p.X,p.Y+1] == occupant && (deplacement & Deplacement_E.I) == Deplacement_E.I)
|
||||||
{
|
{
|
||||||
PointsTrouver.Add(new carrefour_S(new Point(p.X,p.Y+1),Deplacement_E.I));
|
PointsTrouver.Add(new carrefour_S(new Point(p.X,p.Y+1),Deplacement_E.I));
|
||||||
}
|
}
|
||||||
if (p.X-1>=0 && p.Y + 1 < dim && tableauOccupation[p.X-1,p.Y+1] == occupant && (deplacement & Deplacement_E.IG) == Deplacement_E.IG)
|
if (p.X-1>=0 && p.Y + 1 < cfg.taille && tableauOccupation[p.X-1,p.Y+1] == occupant && (deplacement & Deplacement_E.IG) == Deplacement_E.IG)
|
||||||
{
|
{
|
||||||
PointsTrouver.Add(new carrefour_S(new Point(p.X-1,p.Y+1),Deplacement_E.IG));
|
PointsTrouver.Add(new carrefour_S(new Point(p.X-1,p.Y+1),Deplacement_E.IG));
|
||||||
}
|
}
|
||||||
|
@ -285,9 +306,9 @@ namespace go01
|
||||||
|
|
||||||
void printTab(int[,] Tab)
|
void printTab(int[,] Tab)
|
||||||
{
|
{
|
||||||
for(int y = 0;y<dim;y++)
|
for(int y = 0;y<cfg.taille;y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < dim; x++)
|
for (int x = 0; x < cfg.taille; x++)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = (Tab[x, y] !=0 ) ? ConsoleColor.Green : ConsoleColor.White;
|
Console.ForegroundColor = (Tab[x, y] !=0 ) ? ConsoleColor.Green : ConsoleColor.White;
|
||||||
Console.Write(Tab[x, y]);
|
Console.Write(Tab[x, y]);
|
||||||
|
@ -300,12 +321,12 @@ namespace go01
|
||||||
}
|
}
|
||||||
int xyToi(int x, int y)
|
int xyToi(int x, int y)
|
||||||
{
|
{
|
||||||
return x + dim* y;
|
return x + cfg.taille* y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void redrawAllpb()
|
public void redrawAllpb()
|
||||||
{
|
{
|
||||||
for(int i=0;i<dim*dim;i++)
|
for(int i=0;i<cfg.taille*cfg.taille;i++)
|
||||||
{
|
{
|
||||||
if (tableauOccupation[GetX(i), GetY(i)] != Occupant_E.Vide)
|
if (tableauOccupation[GetX(i), GetY(i)] != Occupant_E.Vide)
|
||||||
{
|
{
|
||||||
|
@ -339,8 +360,8 @@ namespace go01
|
||||||
}
|
}
|
||||||
public void resetGoban()
|
public void resetGoban()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < dim; x++)
|
for (int x = 0; x < cfg.taille; x++)
|
||||||
for (int y = 0; y < dim; y++)
|
for (int y = 0; y < cfg.taille; y++)
|
||||||
tableauOccupation[x, y] = Occupant_E.Vide;
|
tableauOccupation[x, y] = Occupant_E.Vide;
|
||||||
redrawAllpb();
|
redrawAllpb();
|
||||||
win = false;
|
win = false;
|
||||||
|
@ -356,14 +377,14 @@ namespace go01
|
||||||
|
|
||||||
public sauvegarde_S sauvegarder()
|
public sauvegarde_S sauvegarder()
|
||||||
{
|
{
|
||||||
sauvegarde_S s = new sauvegarde_S(playerWName, playerBName, ptBlanc,ptNoir, nombreDePionAAligne, dim, tableauOccupation, tour, win);
|
sauvegarde_S s = new sauvegarde_S(ptBlanc,ptNoir, tableauOccupation, tour, win, cfg);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static sauvegarde_S sauvegarder(Goban g)
|
public static sauvegarde_S sauvegarder(Goban g)
|
||||||
{
|
{
|
||||||
sauvegarde_S s = new sauvegarde_S(g.playerWName, g.playerBName, g.ptBlanc, g.ptNoir, g.nombreDePionAAligne, g.dim, g.tableauOccupation, g.tour, g.win);
|
sauvegarde_S s = new sauvegarde_S(g.ptBlanc, g.ptNoir, g.tableauOccupation, g.tour, g.win, g.cfg);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -381,43 +402,43 @@ namespace go01
|
||||||
this.LabelPlayerTurn.Text = "playerW";
|
this.LabelPlayerTurn.Text = "playerW";
|
||||||
Fenetre.Controls.Add(this.LabelPlayerTurn);
|
Fenetre.Controls.Add(this.LabelPlayerTurn);
|
||||||
|
|
||||||
for (int i = 0; i < dim * dim; i++) //Genération du goban
|
for (int i = 0; i < cfg.taille * cfg.taille; i++) //Genération du goban
|
||||||
{
|
{
|
||||||
|
|
||||||
pboxList.Add(new PictureBox());
|
pboxList.Add(new PictureBox());
|
||||||
//pboxList[i].Paint += new PaintEventHandler(this.PaintPb);
|
//pboxList[i].Paint += new PaintEventHandler(this.PaintPb);
|
||||||
pboxList[i].Location = new Point((i % dim) * (Conteneur.Width / dim), (i / dim) * (Conteneur.Height / dim));
|
pboxList[i].Location = new Point((i % cfg.taille) * (Conteneur.Width / cfg.taille), (i / cfg.taille) * (Conteneur.Height / cfg.taille));
|
||||||
pboxList[i].Width = Conteneur.Width / dim;
|
pboxList[i].Width = Conteneur.Width / cfg.taille;
|
||||||
pboxList[i].Height = Conteneur.Height / dim;
|
pboxList[i].Height = Conteneur.Height / cfg.taille;
|
||||||
pboxList[i].SizeMode = PictureBoxSizeMode.StretchImage;
|
pboxList[i].SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
|
|
||||||
if (GetX(i) == 0)
|
if (GetX(i) == 0)
|
||||||
if (GetY(i) == 0)
|
if (GetY(i) == 0)
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.tl;
|
pboxList[i].Image = global::go01.Properties.Resources.tl;
|
||||||
else if (GetY(i) == dim - 1)
|
else if (GetY(i) == cfg.taille - 1)
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.bl;
|
pboxList[i].Image = global::go01.Properties.Resources.bl;
|
||||||
else
|
else
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.l;
|
pboxList[i].Image = global::go01.Properties.Resources.l;
|
||||||
else if (GetY(i) == 0)
|
else if (GetY(i) == 0)
|
||||||
if (GetX(i) == dim - 1)
|
if (GetX(i) == cfg.taille - 1)
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.tr;
|
pboxList[i].Image = global::go01.Properties.Resources.tr;
|
||||||
else
|
else
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.t;
|
pboxList[i].Image = global::go01.Properties.Resources.t;
|
||||||
else if (GetY(i) == dim - 1)
|
else if (GetY(i) == cfg.taille - 1)
|
||||||
if (GetX(i) == dim - 1)
|
if (GetX(i) == cfg.taille - 1)
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.br;
|
pboxList[i].Image = global::go01.Properties.Resources.br;
|
||||||
else
|
else
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.b;
|
pboxList[i].Image = global::go01.Properties.Resources.b;
|
||||||
else if (GetX(i) == dim - 1)
|
else if (GetX(i) == cfg.taille - 1)
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.r;
|
pboxList[i].Image = global::go01.Properties.Resources.r;
|
||||||
else
|
else
|
||||||
pboxList[i].Image = global::go01.Properties.Resources.m;
|
pboxList[i].Image = global::go01.Properties.Resources.m;
|
||||||
if (initTableauOccupation)
|
if (initTableauOccupation)
|
||||||
{
|
{
|
||||||
tableauOccupation[i % dim, i / dim] = Occupant_E.Vide;
|
tableauOccupation[i % cfg.taille, i / cfg.taille] = Occupant_E.Vide;
|
||||||
|
|
||||||
}
|
}
|
||||||
pboxList[i].Name = (i % dim).ToString() + ";" + (i / dim).ToString();
|
pboxList[i].Name = (i % cfg.taille).ToString() + ";" + (i / cfg.taille).ToString();
|
||||||
pboxList[i].Click += new System.EventHandler(this.pictureBox1_Click);
|
pboxList[i].Click += new System.EventHandler(this.pictureBox1_Click);
|
||||||
pboxList[i].Paint += new PaintEventHandler(this.PaintPb);
|
pboxList[i].Paint += new PaintEventHandler(this.PaintPb);
|
||||||
Conteneur.Controls.Add(pboxList[i]);
|
Conteneur.Controls.Add(pboxList[i]);
|
||||||
|
|
|
@ -23,7 +23,7 @@ int dim; int nbPionAlign; string playerW; string playerB;
|
||||||
public Plateau(Goban.sauvegarde_S s)
|
public Plateau(Goban.sauvegarde_S s)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.Text = $"Morpion {s.dimGoban}x{s.dimGoban}";
|
this.Text = $"Morpion {s.cfg.taille}x{s.cfg.taille}";
|
||||||
g = new Goban(this, pictureBox1, s);
|
g = new Goban(this, pictureBox1, s);
|
||||||
}
|
}
|
||||||
public Plateau(int dim, int nbPionAlign, string playerW, string playerB)
|
public Plateau(int dim, int nbPionAlign, string playerW, string playerB)
|
||||||
|
|
|
@ -16,12 +16,12 @@ namespace go01
|
||||||
{
|
{
|
||||||
public partial class RejoindrePartieReseau_client : Form
|
public partial class RejoindrePartieReseau_client : Form
|
||||||
{
|
{
|
||||||
socketPlateauBase.ConfigGo_S cfg;
|
Goban.ConfigGo_S cfg;
|
||||||
Thread ecouteThread;
|
Thread ecouteThread;
|
||||||
System.Threading.Timer timerTTLdtListPart;
|
System.Threading.Timer timerTTLdtListPart;
|
||||||
private DataTable dtListPart;
|
private DataTable dtListPart;
|
||||||
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
|
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
|
||||||
|
Plateau p;
|
||||||
/*public struct partie_S
|
/*public struct partie_S
|
||||||
{
|
{
|
||||||
public string uid, partName, joueurAdverseName, ip;
|
public string uid, partName, joueurAdverseName, ip;
|
||||||
|
@ -61,7 +61,7 @@ namespace go01
|
||||||
dtListPart = new DataTable();
|
dtListPart = new DataTable();
|
||||||
|
|
||||||
dtListPart.Columns.Add("uid", typeof(string));
|
dtListPart.Columns.Add("uid", typeof(string));
|
||||||
dtListPart.Columns.Add("partName", typeof(socketPlateauBase.ConfigGo_S));
|
dtListPart.Columns.Add("partName", typeof(Goban.ConfigGo_S));
|
||||||
dtListPart.Columns.Add("playerName", typeof(string));
|
dtListPart.Columns.Add("playerName", typeof(string));
|
||||||
dtListPart.Columns.Add("ip", typeof(string));
|
dtListPart.Columns.Add("ip", typeof(string));
|
||||||
dtListPart.Columns.Add("port", typeof(int));//timeStamp
|
dtListPart.Columns.Add("port", typeof(int));//timeStamp
|
||||||
|
@ -93,7 +93,7 @@ namespace go01
|
||||||
byte[] ClientRequestData = Server.Receive(ref ClientEp);
|
byte[] ClientRequestData = Server.Receive(ref ClientEp);
|
||||||
using (MemoryStream ms = new MemoryStream(ClientRequestData))
|
using (MemoryStream ms = new MemoryStream(ClientRequestData))
|
||||||
{
|
{
|
||||||
socketPlateauBase.ConfigGo_S cfgGo = (socketPlateauBase.ConfigGo_S)binaryFormatter.Deserialize(ms);
|
Goban.ConfigGo_S cfgGo = (Goban.ConfigGo_S)binaryFormatter.Deserialize(ms);
|
||||||
Invoke(new Action(() => { ajoutPartie(cfgGo, ClientEp.Address.ToString()); }));
|
Invoke(new Action(() => { ajoutPartie(cfgGo, ClientEp.Address.ToString()); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,11 +104,11 @@ namespace go01
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void ajoutPartie(socketPlateauBase.ConfigGo_S cfgGo, string ip)
|
public void ajoutPartie(Goban.ConfigGo_S cfgGo, string ip)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(dtListPart.Select($"uid = '{cfgGo.Uid}'").Length==0)
|
if(dtListPart.Select($"uid = '{cfgGo.Uid}'").Length==0)
|
||||||
dtListPart.Rows.Add(cfgGo.Uid, cfgGo, cfgGo.NomJoeurServeur, cfgGo.IpServeur, cfgGo.port, DateTime.Now);
|
dtListPart.Rows.Add(cfgGo.Uid, cfgGo, cfgGo.NomJoeurBlanc==""? cfgGo.NomJoeurNoir: cfgGo.NomJoeurBlanc, cfgGo.IpServeur, cfgGo.port, DateTime.Now);
|
||||||
//lock (DgvPart) ;
|
//lock (DgvPart) ;
|
||||||
dtListPart.Select($"uid = '{cfgGo.Uid}'")[0]["timeStamp"] = DateTime.Now;
|
dtListPart.Select($"uid = '{cfgGo.Uid}'")[0]["timeStamp"] = DateTime.Now;
|
||||||
DgvPart.DataSource = dtListPart;
|
DgvPart.DataSource = dtListPart;
|
||||||
|
@ -124,7 +124,6 @@ namespace go01
|
||||||
dgvPart.Rows.Remove(row);
|
dgvPart.Rows.Remove(row);
|
||||||
dgvPart.Refresh();
|
dgvPart.Refresh();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +148,7 @@ namespace go01
|
||||||
{
|
{
|
||||||
if (dgvPart.SelectedRows.Count <= 0)
|
if (dgvPart.SelectedRows.Count <= 0)
|
||||||
return;
|
return;
|
||||||
cfg = (socketPlateauBase.ConfigGo_S)dgvPart.SelectedRows[0].Cells["partName"].Value;
|
cfg = (Goban.ConfigGo_S)dgvPart.SelectedRows[0].Cells["partName"].Value;
|
||||||
tbIpServ.Text = cfg.IpServeur.ToString();
|
tbIpServ.Text = cfg.IpServeur.ToString();
|
||||||
tbPort.Text = cfg.port.ToString();
|
tbPort.Text = cfg.port.ToString();
|
||||||
}
|
}
|
||||||
|
@ -158,8 +157,13 @@ namespace go01
|
||||||
{
|
{
|
||||||
if (dgvPart.SelectedRows.Count <= 0)
|
if (dgvPart.SelectedRows.Count <= 0)
|
||||||
return;
|
return;
|
||||||
cfg = (socketPlateauBase.ConfigGo_S)dgvPart.SelectedRows[0].Cells["partName"].Value;
|
cfg = (Goban.ConfigGo_S)dgvPart.SelectedRows[0].Cells["partName"].Value;
|
||||||
cfg.NomJoeurClient = tbPlayername.Text;
|
if(cfg.NomJoeurBlanc == "")
|
||||||
|
cfg.NomJoeurBlanc = tbPlayername.Text;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.NomJoeurBlanc = tbPlayername.Text;
|
||||||
|
}
|
||||||
socketPlateauCLI sc = new socketPlateauCLI(cfg, null, new socketPlateauCLI.OnConnected(SocketCoonected));
|
socketPlateauCLI sc = new socketPlateauCLI(cfg, null, new socketPlateauCLI.OnConnected(SocketCoonected));
|
||||||
/*sc.
|
/*sc.
|
||||||
sc.senCmd(new socketPlateauBase.CommandeSocket_S(socketPlateauBase.commande_E.Join, cfg));*/
|
sc.senCmd(new socketPlateauBase.CommandeSocket_S(socketPlateauBase.commande_E.Join, cfg));*/
|
||||||
|
@ -173,9 +177,11 @@ namespace go01
|
||||||
//################################################################################################
|
//################################################################################################
|
||||||
//################################################################################################
|
//################################################################################################
|
||||||
Console.WriteLine("CONNECTION ETABLEIE");
|
Console.WriteLine("CONNECTION ETABLEIE");
|
||||||
Plateau p = new Plateau(cfg.Taille, cfg.PionAligner, cfg.NomJoeurServeur, cfg.NomJoeurClient);
|
p = new Plateau(cfg.taille, cfg.PionAligner, cfg.NomJoeurBlanc, cfg.NomJoeurNoir);
|
||||||
|
p.Show();
|
||||||
|
|
||||||
//this.Hide();
|
//this.Hide();
|
||||||
p.ShowDialog();
|
// p.ShowDialog();
|
||||||
//this.Close();
|
//this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@
|
||||||
<Compile Include="socketPlateauCLI.cs" />
|
<Compile Include="socketPlateauCLI.cs" />
|
||||||
<Compile Include="socketPlateauSRV.cs" />
|
<Compile Include="socketPlateauSRV.cs" />
|
||||||
<Compile Include="socketPlateauBase.cs" />
|
<Compile Include="socketPlateauBase.cs" />
|
||||||
<Compile Include="socketPlateauInterface.cs" />
|
|
||||||
<Compile Include="socketPlateauEventArgs.cs" />
|
<Compile Include="socketPlateauEventArgs.cs" />
|
||||||
|
<Compile Include="socketPlateauBase_Interface.cs" />
|
||||||
<Compile Include="TextBoxStreamWriter.cs" />
|
<Compile Include="TextBoxStreamWriter.cs" />
|
||||||
<EmbeddedResource Include="CreerPartieReseau_serv.resx">
|
<EmbeddedResource Include="CreerPartieReseau_serv.resx">
|
||||||
<DependentUpon>CreerPartieReseau_serv.cs</DependentUpon>
|
<DependentUpon>CreerPartieReseau_serv.cs</DependentUpon>
|
||||||
|
|
|
@ -30,44 +30,6 @@ namespace go01
|
||||||
data = dt;
|
data = dt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[Serializable]
|
|
||||||
public struct ConfigGo_S
|
|
||||||
{
|
|
||||||
private string uid;
|
|
||||||
public string Uid { get { return uid; } }
|
|
||||||
private string partName;
|
|
||||||
public string PartName { get { return partName; } }
|
|
||||||
public string NomJoeurClient;
|
|
||||||
private string nomJoeurServeur;
|
|
||||||
public string NomJoeurServeur { get { return nomJoeurServeur; } }
|
|
||||||
private int taille;
|
|
||||||
public int Taille { get { return taille; } }
|
|
||||||
private int pionaAligner;
|
|
||||||
public int PionAligner { get { return pionaAligner; } }
|
|
||||||
private IPAddress ipServeur;
|
|
||||||
public IPAddress IpServeur { get => ipServeur; }
|
|
||||||
public readonly int port;
|
|
||||||
|
|
||||||
public ConfigGo_S(string Uid, string PartName, string NomJoeurClient, string NomJoeurServeur, int Taille, int PionaAligner, IPAddress ipServeur, int port)
|
|
||||||
{
|
|
||||||
this.uid = Uid;
|
|
||||||
this.partName = PartName;
|
|
||||||
this.NomJoeurClient = NomJoeurClient;
|
|
||||||
this.nomJoeurServeur = NomJoeurServeur;
|
|
||||||
this.taille = Taille;
|
|
||||||
this.pionaAligner = PionaAligner;
|
|
||||||
this.ipServeur = ipServeur;
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return partName;
|
|
||||||
}
|
|
||||||
public static implicit operator string(ConfigGo_S part)
|
|
||||||
{
|
|
||||||
return part.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
#region variable
|
#region variable
|
||||||
protected Socket socServ, socCli;
|
protected Socket socServ, socCli;
|
||||||
|
@ -95,13 +57,12 @@ namespace go01
|
||||||
protected static Boolean connexionEtablie = false;
|
protected static Boolean connexionEtablie = false;
|
||||||
|
|
||||||
protected Goban plateauDeJeu;
|
protected Goban plateauDeJeu;
|
||||||
protected ConfigGo_S cfgGo;
|
protected Goban.ConfigGo_S cfgGo;
|
||||||
#endregion
|
#endregion
|
||||||
public delegate void OnReceived(object myObject, socketPlateauServReception myArgs);
|
public delegate void OnReceived(object myObject, socketPlateauServReception myArgs);
|
||||||
public event OnReceived onReceived;
|
public event OnReceived onReceived;
|
||||||
|
|
||||||
|
public socketPlateauBase(TypeSocket_E socF, Goban.ConfigGo_S cfgGo, Goban g)
|
||||||
public socketPlateauBase(TypeSocket_E socF, ConfigGo_S cfgGo, Goban g)
|
|
||||||
{
|
{
|
||||||
plateauDeJeu = g;
|
plateauDeJeu = g;
|
||||||
adresseIpCourante = cfgGo.IpServeur;
|
adresseIpCourante = cfgGo.IpServeur;
|
||||||
|
@ -116,25 +77,10 @@ namespace go01
|
||||||
var netStream = new NetworkStream(sArg, true);
|
var netStream = new NetworkStream(sArg, true);
|
||||||
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
|
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
|
||||||
CommandeSocket_S cmd = (CommandeSocket_S)binaryFormatter.Deserialize(netStream);
|
CommandeSocket_S cmd = (CommandeSocket_S)binaryFormatter.Deserialize(netStream);
|
||||||
try { onReceived(this, new socketPlateauServReception(cmd)); } catch { }
|
try { onReceived?.Invoke(this, new socketPlateauServReception(cmd)); } catch (Exception e) { Console.WriteLine(e); }
|
||||||
switch (cmd.commande)
|
|
||||||
{
|
|
||||||
case commande_E.Join:
|
|
||||||
break;
|
|
||||||
case commande_E.Leave:
|
|
||||||
break;
|
|
||||||
case commande_E.Place:
|
|
||||||
break;
|
|
||||||
case commande_E.WhoTurn:
|
|
||||||
break;
|
|
||||||
case commande_E.Win:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Received(cmd);
|
|
||||||
InitialiserReception(sArg);
|
InitialiserReception(sArg);
|
||||||
}
|
}
|
||||||
protected abstract void Received(CommandeSocket_S cmd);
|
public void senCmd(object cmd)
|
||||||
public void senCmd(CommandeSocket_S cmd)
|
|
||||||
{
|
{
|
||||||
var netStream = new NetworkStream(socCli, true);
|
var netStream = new NetworkStream(socCli, true);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace go01
|
||||||
public delegate void OnJoinACK(object myObject, socketPlateauServACKArgs myArgs);
|
public delegate void OnJoinACK(object myObject, socketPlateauServACKArgs myArgs);
|
||||||
public event OnJoinACK onJoinACK;
|
public event OnJoinACK onJoinACK;
|
||||||
|
|
||||||
public socketPlateauCLI(ConfigGo_S cfgGo, Goban g) : base(TypeSocket_E.Client, cfgGo, g)
|
public socketPlateauCLI(Goban.ConfigGo_S cfgGo, Goban g) : base(TypeSocket_E.Client, cfgGo, g)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -29,11 +29,11 @@ namespace go01
|
||||||
MessageBox.Show("Connexion impossible : " + ee.Message);
|
MessageBox.Show("Connexion impossible : " + ee.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public socketPlateauCLI(ConfigGo_S cfgGo, Goban g, OnJoinACK onJoinACK) : this(cfgGo, g)
|
public socketPlateauCLI(Goban.ConfigGo_S cfgGo, Goban g, OnJoinACK onJoinACK) : this(cfgGo, g)
|
||||||
{
|
{
|
||||||
this.onJoinACK = onJoinACK;
|
this.onJoinACK = onJoinACK;
|
||||||
}
|
}
|
||||||
public socketPlateauCLI(ConfigGo_S cfgGo, Goban g, OnConnected onConnected) : this(cfgGo, g)
|
public socketPlateauCLI(Goban.ConfigGo_S cfgGo, Goban g, OnConnected onConnected) : this(cfgGo, g)
|
||||||
{
|
{
|
||||||
this.onConnected = onConnected;
|
this.onConnected = onConnected;
|
||||||
}
|
}
|
||||||
|
@ -43,17 +43,12 @@ namespace go01
|
||||||
Socket sTmp = (Socket)iAR.AsyncState;
|
Socket sTmp = (Socket)iAR.AsyncState;
|
||||||
if (sTmp.Connected) {
|
if (sTmp.Connected) {
|
||||||
connexionEtablie = true;
|
connexionEtablie = true;
|
||||||
try { onConnected(this, new socketPlateauConnected(cfgGo)); } catch { }
|
try { onConnected?.Invoke(this, new socketPlateauConnected(cfgGo)); } catch (Exception e) { Console.WriteLine(e); }
|
||||||
senCmd(new CommandeSocket_S(commande_E.Join, cfgGo));
|
|
||||||
InitialiserReception(sTmp);
|
InitialiserReception(sTmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
else { MessageBox.Show("Serveur innacessible"); }
|
else { MessageBox.Show("Serveur innacessible"); }
|
||||||
|
|
||||||
}
|
}
|
||||||
protected override void Received(CommandeSocket_S cmd)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ namespace go01
|
||||||
{
|
{
|
||||||
public class socketPlateauServJoinArgs : EventArgs
|
public class socketPlateauServJoinArgs : EventArgs
|
||||||
{
|
{
|
||||||
public socketPlateauBase.ConfigGo_S ConfigGo;
|
public Goban.ConfigGo_S ConfigGo;
|
||||||
public socketPlateauServJoinArgs(socketPlateauBase.ConfigGo_S cfg)
|
public socketPlateauServJoinArgs(Goban.ConfigGo_S cfg)
|
||||||
{
|
{
|
||||||
this.ConfigGo = cfg;
|
this.ConfigGo = cfg;
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,9 @@ namespace go01
|
||||||
}
|
}
|
||||||
public class socketPlateauConnected : EventArgs
|
public class socketPlateauConnected : EventArgs
|
||||||
{
|
{
|
||||||
public socketPlateauBase.ConfigGo_S ConfigGo;
|
public Goban.ConfigGo_S ConfigGo;
|
||||||
|
|
||||||
public socketPlateauConnected(socketPlateauBase.ConfigGo_S cfg)
|
public socketPlateauConnected(Goban.ConfigGo_S cfg)
|
||||||
{
|
{
|
||||||
this.ConfigGo = cfg;
|
this.ConfigGo = cfg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace go01
|
|
||||||
{
|
|
||||||
public interface socketPlateauInterface
|
|
||||||
{
|
|
||||||
void InitialiserReception(Socket sArg);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,20 +27,21 @@ namespace go01
|
||||||
public event OnDemandeCo onDemandeCo;
|
public event OnDemandeCo onDemandeCo;
|
||||||
public delegate void OnConnected(object myObject, socketPlateauConnected myArgs);
|
public delegate void OnConnected(object myObject, socketPlateauConnected myArgs);
|
||||||
public event OnConnected onConnected;
|
public event OnConnected onConnected;
|
||||||
|
public event EventHandler onReceive;
|
||||||
#endregion
|
#endregion
|
||||||
public socketPlateauSRV(ConfigGo_S cfgGo, Goban g) : base(TypeSocket_E.Serveur, cfgGo, g)
|
public socketPlateauSRV(Goban.ConfigGo_S cfgGo, Goban g) : base(TypeSocket_E.Serveur, cfgGo, g)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public socketPlateauSRV(ConfigGo_S cfgGo, Goban g, OnJoinACK onJoinACK) : this(cfgGo, g)
|
public socketPlateauSRV(Goban.ConfigGo_S cfgGo, Goban g, OnJoinACK onJoinACK) : this(cfgGo, g)
|
||||||
{
|
{
|
||||||
this.onJoinACK = onJoinACK;
|
this.onJoinACK = onJoinACK;
|
||||||
}
|
}
|
||||||
public socketPlateauSRV(ConfigGo_S cfgGo, Goban g, OnConnected onConnected) : this(cfgGo, g)
|
public socketPlateauSRV(Goban.ConfigGo_S cfgGo, Goban g, OnConnected onConnected) : this(cfgGo, g)
|
||||||
{
|
{
|
||||||
this.onConnected = onConnected;
|
this.onConnected = onConnected;
|
||||||
}
|
}
|
||||||
public socketPlateauSRV(ConfigGo_S cfgGo, Goban g, OnJoinServ onJoinServ) : this(cfgGo, g)
|
public socketPlateauSRV(Goban.ConfigGo_S cfgGo, Goban g, OnJoinServ onJoinServ) : this(cfgGo, g)
|
||||||
{
|
{
|
||||||
this.onJoinServ = onJoinServ;
|
this.onJoinServ = onJoinServ;
|
||||||
}
|
}
|
||||||
|
@ -79,12 +80,9 @@ namespace go01
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
onDemandeCo(this, new socketPlateauServDemandeCo());
|
onDemandeCo?.Invoke(this, new socketPlateauServDemandeCo());
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e) { Console.WriteLine(e); }
|
||||||
if (socFlag == TypeSocket_E.Serveur && !connexionEtablie)
|
if (socFlag == TypeSocket_E.Serveur && !connexionEtablie)
|
||||||
{
|
{
|
||||||
Socket sTmp = (Socket)iAR.AsyncState;
|
Socket sTmp = (Socket)iAR.AsyncState;
|
||||||
|
@ -94,7 +92,7 @@ namespace go01
|
||||||
Console.WriteLine($"Connexion effectuée par {((IPEndPoint)socCli.RemoteEndPoint).Address}");
|
Console.WriteLine($"Connexion effectuée par {((IPEndPoint)socCli.RemoteEndPoint).Address}");
|
||||||
#endif
|
#endif
|
||||||
connexionEtablie = true;
|
connexionEtablie = true;
|
||||||
try { onConnected(this, new socketPlateauConnected(cfgGo)); } catch { }
|
try { onConnected?.Invoke(this, new socketPlateauConnected(cfgGo)); } catch (Exception e) { Console.WriteLine(e); }
|
||||||
timerBroadcast.Dispose();
|
timerBroadcast.Dispose();
|
||||||
InitialiserReception(socCli);
|
InitialiserReception(socCli);
|
||||||
}
|
}
|
||||||
|
@ -106,23 +104,5 @@ namespace go01
|
||||||
socCli.Close();
|
socCli.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Received(CommandeSocket_S cmd)
|
|
||||||
{
|
|
||||||
switch (cmd.commande)
|
|
||||||
{
|
|
||||||
case commande_E.Join:
|
|
||||||
try{ onJoinServ(this, new socketPlateauServJoinArgs((ConfigGo_S)cmd.data)); } catch { }
|
|
||||||
break;
|
|
||||||
case commande_E.Leave:
|
|
||||||
break;
|
|
||||||
case commande_E.Place:
|
|
||||||
break;
|
|
||||||
case commande_E.WhoTurn:
|
|
||||||
break;
|
|
||||||
case commande_E.Win:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue