Пример #1
0
        public async Task <bool> Connect(Uri pRemote)
        {
            // Fermeture des précédents connexions
            Close();

            Socket = _factory.BuildSocket();
            Socket.OnConnectionChanged += OnConnectionChangedHandler;
            Socket.OnMessageReceived   += OnMessageReceivedHandler;
            var isConnected = await Socket.Connect(pRemote);

            return(Socket.IsConnected);
        }
Пример #2
0
 private void RegisterSocket(TcpClient pNewSocket)
 {
     if (pNewSocket != null)
     {
         try
         {
             Client = _factory.BuildSocket();
             Client.UseConnectedSocket(pNewSocket);
         }
         catch (Exception e)
         {
             LOGGER.Error(e, "Une erreur est survenue durant la prisez en charge d'une nouvelle connexion provenant de {0}", pNewSocket?.Client?.RemoteEndPoint);
             pNewSocket.Close();
             Client = null;
         }
     }
 }