using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace go01 { class socketPlateauCLI : socketPlateauBase { public delegate void OnConnected(object myObject, socketPlateauConnected myArgs); public event OnConnected onConnected; public delegate void OnJoinACK(object myObject, socketPlateauServACKArgs myArgs); public event OnJoinACK onJoinACK; public socketPlateauCLI(ConfigGo_S cfgGo, Goban g) : base(TypeSocket_E.Client, cfgGo, g) { try { socCli = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socCli.BeginConnect(new IPEndPoint(cfgGo.IpServeur, port), new AsyncCallback(SurConnection), socCli); } catch (Exception ee) { MessageBox.Show("Connexion impossible : " + ee.Message); } } public socketPlateauCLI(ConfigGo_S cfgGo, Goban g, OnJoinACK onJoinACK) : this(cfgGo, g) { this.onJoinACK = onJoinACK; } public socketPlateauCLI(ConfigGo_S cfgGo, Goban g, OnConnected onConnected) : this(cfgGo, g) { this.onConnected = onConnected; } private void SurConnection(IAsyncResult iAR) { Socket sTmp = (Socket)iAR.AsyncState; if (sTmp.Connected) { connexionEtablie = true; try { onConnected(this, new socketPlateauConnected(cfgGo)); } catch { } senCmd(new CommandeSocket_S(commande_E.Join, cfgGo)); InitialiserReception(sTmp); } else { MessageBox.Show("Serveur innacessible"); } } protected override void Received(CommandeSocket_S cmd) { throw new NotImplementedException(); } } }