예제 #1
0
 /// <summary>
 /// Escucha mensajes UDP recibidos
 /// Si ocurre un error se notifica en errorNetworkingHandler
 /// </summary>
 private void listenUDPMessages()
 {
     try
     {
         while (true)
         {
             IPEndPoint ipEndPoint = new IPEndPoint(tcpAddress, netData.UdpPort);
             byte[]     buffer     = udpClient.Receive(ref ipEndPoint);
             if (buffer.Length > 4)
             {
                 Int32 size = BitConverter.ToInt32(buffer, 0);
                 if (buffer.Length == 4 + size)
                 {
                     byte[] body = new byte[size];
                     Array.Copy(buffer, 4, body, 0, size);
                     NetMessage message = new NetMessage(body);
                     udpMessageQueue.put(message);
                 }
             }
         }
     }
     catch (ThreadAbortException e)
     {
         throw e;
     }
     catch (Exception e)
     {
         commHandler.informationNetworkingHandler("UDP WARNING: udp client has stopped!!! " + e.Message);
     }
 }
예제 #2
0
 /// <summary>
 /// Agrega mensajes TCP recibidos a la cola
 /// </summary>
 /// <param name="message">el mensaje recibido</param>
 private void addTCPMessages(NetMessage message)
 {
     try
     {
         //TODO PARAMETRIZAR
         if (tcpMessageQueue.size() < 50)
         {
             tcpMessageQueue.put(message);
         }
         else
         {
             commHandler.informationNetworkingHandler("TCP WARNING: TCP message dropped");
         }
     }
     catch (ThreadAbortException e)
     {
         throw e;
     }
 }