示例#1
0
 public void ListenForMessages()
 {
     while (isActive)
     {
         var envelope = GetIncomingMessages();
         if (envelope != null)
         {
             try
             {
                 ComService.HandleIncomingMessage(envelope);
             }
             catch (Exception e)
             {
                 Log.Error($"Problem encountered while handling incoming message...");
                 Log.Error(e);
             }
             waitHandle.Set();
         }
     }
 }
示例#2
0
        public void ListenForMessages()
        {
            while (isActive)
            {
                var envelope = GetIncomingMessages();
                if (envelope != null)
                {
                    try
                    {
                        ComService.HandleIncomingMessage(envelope);
                    }
                    catch (Exception e)
                    {
                        Log.Error($"Problem encountered while handling incoming message...");
                        Log.Error(e);
                    }

                    waitHandle.Set();//TODO: <- I don't think this is needed anymore?? -Dsphar 4/7/2019
                }
            }
        }
示例#3
0
        private Envelope GetIncomingMessages()
        {
            TcpEnvelope newEnvelope = null;

            //Docs say that AcceptTcpClient() is a blocking call, so it won't just spin it's wheels. There is an asynch, AcceptTcpClientAsync.
            Log.Info($"Waiting for TCP connection on port ${((IPEndPoint)myTcpListenerClient.LocalEndpoint).Port}");

            System.Net.Sockets.TcpClient client = myTcpListenerClient.AcceptTcpClient();

            try
            {
                Log.Info($"Incoming TCP Connection established with {((IPEndPoint)client.Client.RemoteEndPoint).ToString()}");
                ComService.AddTcpClient(client);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            return(newEnvelope);
        }