/// <summary>
/// Methode callback appelée lorsque la connexion est effective.
/// </summary>
/// <param name="result"></param>
private void OnConnect(IAsyncResult result)
{
try
{
_tcpClient.EndConnect(result);
_connected = true;
NetworkStream stream = _tcpClient.GetStream();
if (stream != null)
{
stream.BeginRead(_buffer, 0, _buffer.Length, OnDataReceived, this);
if (this.ReferenceDelegate != null)
{
this.ReferenceDelegate.OnConnect(this);
}
}
}
catch (Exception e)
{
if (this.ReferenceDelegate != null)
{
this.ReferenceDelegate.OnError(e, this);
}
}
}