Ejemplo n.º 1
0
    /// <summary>
    /// Méthode Thread pour la récéption de message !!!
    /// </summary>
    /// <param name=""></param>
    private async void reading()
    {
        this.error  = -1;
        messageRecu = new byte[1024];
        messageRecu.Initialize();
        byte[] message_test = new byte[1024];
        message_test.Initialize();
        try
        {
            while (true)
            {
                this.form.setReadyClient(true);
                await stream.ReadAsync(messageRecu, 0, messageRecu.Length);

                this.updateOutputLog("ICI " + Encoding.ASCII.GetString(messageRecu), 0);
                dt          = BinaryDeserializeObject(messageRecu);
                messageRecu = new byte[1024];
                messageRecu.Initialize();
            }
        }
        catch (Exception ex)
        {
            CloseConnection();
            this.updateOutputLog(ex.Message, -1);
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Methode qui serialise un objet en tableau de Byte. Cette méthode sert à préparer un message à envoyé
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 private static byte[] BinarySerializeObject(DataTransit b)
 {
     if (b == null)
     {
         return(new byte[0]);
     }
     else
     {
         MemoryStream    streamMemory = new MemoryStream();
         BinaryFormatter formatter    = new BinaryFormatter();
         formatter.Serialize(streamMemory, b);
         return(streamMemory.ToArray());
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Message qui lance la préparation du message
 /// </summary>
 /// <param name="b">Passage de Balle</param>
 public static void prepareSendData(DataTransit b)
 {
     messageSend      = BinarySerializeObject(b);
     messageAvailable = true;
 }