mil.dod.th.remote.client.integration/src/mil/dod/th/remote/client/integration/MessageListener.java
public <T> T waitForMessage(final Namespace namespace, final ProtocolMessageEnum dataMessageType, int timeout, 
            TimeUnit unit)
    {
        final List<RemoteMessage<?>> invalidMsgs = new ArrayList<>();
        
        Future<T> future = m_Executor.submit(new Callable<T>()
        {
            @SuppressWarnings("unchecked")
            @Override
            public T call() throws Exception
            {
                while (true)
                {
                    RemoteMessage<?> msg = m_ReceivedMsgs.poll(500, TimeUnit.MILLISECONDS);
                    if (msg == null || msg.getDataMessage() == null)
                    {
                        continue;
                    }
                    if (msg.getNamespace().equals(namespace) &&
                            msg.getDataMessageType().equals(dataMessageType))
                    {
                        return (T)msg.getDataMessage();
                    }
                    else
                    {
                        invalidMsgs.add(msg);
                    }
                }
            }
        });
        
        try
        {
            return future.get(timeout, unit);
        }
        catch (InterruptedException | ExecutionException e)
        {
            throw new IllegalStateException(e);
        }
        catch (TimeoutException e)
        {
            fail(String.format("Expecting %s:%s, but got: %s", namespace, dataMessageType,
                    Lists.transform(invalidMsgs, new Function<RemoteMessage<?>, String>()
                    {    
                        @Override
                        public String apply(RemoteMessage<?> msg)
                        {
                            return msg.getNamespace() + ":" + msg.getDataMessageType();
                        }
                    })));
            throw new IllegalStateException();
        }
    }
/**
     * Wait for the message with the given namespace and data message type.
     */
Wait for the message with the given namespace and data message type.
Wait for the message with the given namespace and data message type .
public <T> T waitForMessage(final Namespace namespace, final ProtocolMessageEnum dataMessageType, int timeout, 
            TimeUnit unit)
    {
        final List<RemoteMessage<?>> invalidMsgs = new ArrayList<>();
        Future<T> future = m_Executor.submit(new Callable<T>()
        {
            @SuppressWarnings("unchecked")
            @Override
            public T call() throws Exception
            {
                while (true)
                {
                    RemoteMessage<?> msg = m_ReceivedMsgs.poll(500, TimeUnit.MILLISECONDS);
                    if (msg == null || msg.getDataMessage() == null)
                    {
                        continue;
                    }
                    if (msg.getNamespace().equals(namespace) &&
                            msg.getDataMessageType().equals(dataMessageType))
                    {
                        return (T)msg.getDataMessage();
                    }
                    else
                    {
                        invalidMsgs.add(msg);
                    }
                }
            }
        });
        try
        {
            return future.get(timeout, unit);
        }
        catch (InterruptedException | ExecutionException e)
        {
            throw new IllegalStateException(e);
        }
        catch (TimeoutException e)
        {
            fail(String.format("Expecting %s:%s, but got: %s", namespace, dataMessageType,
                    Lists.transform(invalidMsgs, new Function<RemoteMessage<?>, String>()
                    {    
                        @Override
                        public String apply(RemoteMessage<?> msg)
                        {
                            return msg.getNamespace() + ":" + msg.getDataMessageType();
                        }
                    })));
            throw new IllegalStateException();
        }
    }
public < T > T waitForMessage ( final Namespace namespace , final ProtocolMessageEnum dataMessageType , int timeout , TimeUnit unit ) { final List < RemoteMessage < ? > > invalidMsgs = new ArrayList < > ( ) ; Future < T > future = m_Executor . submit ( new Callable < T > ( ) { @ SuppressWarnings ( "unchecked" ) @ Override public T call ( ) throws Exception { while ( true ) { RemoteMessage < ? > msg = m_ReceivedMsgs . poll ( 500 , TimeUnit . MILLISECONDS ) ; if ( msg == null || msg . getDataMessage ( ) == null ) { continue ; } if ( msg . getNamespace ( ) . equals ( namespace ) && msg . getDataMessageType ( ) . equals ( dataMessageType ) ) { return ( T ) msg . getDataMessage ( ) ; } else { invalidMsgs . add ( msg ) ; } } } } ) ; try { return future . get ( timeout , unit ) ; } catch ( InterruptedException | ExecutionException e ) { throw new IllegalStateException ( e ) ; } catch ( TimeoutException e ) { fail ( String . format ( "Expecting %s:%s, but got: %s" , namespace , dataMessageType , Lists . transform ( invalidMsgs , new Function < RemoteMessage < ? > , String > ( ) { @ Override public String apply ( RemoteMessage < ? > msg ) { return msg . getNamespace ( ) + ":" + msg . getDataMessageType ( ) ; } } ) ) ) ; throw new IllegalStateException ( ) ; } }
Wait for the message with the given namespace and data message type.
Wait for the message with the given namespace and data message type .