mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/RemoteEventRegistration.java
public static int regRemoteEventMessages(Socket socket, String[] topic, String filter, 
            RemoteTypesGen.LexiconFormat.Enum format) throws 
        IOException
    {
        //create registration message
        EventRegistrationRequestData.Builder requestMessage = EventRegistrationRequestData.newBuilder()
                .addAllTopic(Arrays.asList(topic));

        //append required fields
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, true);
        
        //append filter if filter was sent
        if (filter != null)
        {
            requestMessage.setFilter(filter);
        }
        
        if (format != null)
        {
            requestMessage.setObjectFormat(format);
        }

        //create TH message to send
        TerraHarvestMessage message = TestEventAdminNamespace.createEventAdminMessage(
            EventAdminMessageType.EventRegistrationRequest, requestMessage.build());
        try
        {
            //send out message
            message.writeDelimitedTo(socket.getOutputStream());
        }
        catch (IOException exception)
        {
            fail("Unable to send request to receive remote events" + exception.getMessage());
        }
        //used to return reg id
        int registrationId = -1;
        
        MessageListener listener = new MessageListener(socket);
        //start thread message listener
        Message messageRcvd = 
            listener.waitForMessage(Namespace.EventAdmin, EventAdminMessageType.EventRegistrationResponse, 1000);
            
        try
        {
            EventAdminNamespace namespaceResponse = (EventAdminNamespace) messageRcvd;
            assertThat(namespaceResponse.getType(), is(EventAdminMessageType.EventRegistrationResponse));
            EventRegistrationResponseData typeResponse = EventRegistrationResponseData.
                parseFrom(namespaceResponse.getData());
            //save the reg id for later deregistration
            registrationId = typeResponse.getId();
        }
        catch (IOException exception)
        {
            fail("Unable to parse response to receive remote events" + exception.getMessage());
        }
        return registrationId;
    }
/**
     * Method send registration message listening for remote message events on the given communication avenue.
     * To start the listening see 
     * {@link mil.dod.th.ose.remote.integration.MessageListener#waitForMessage}.
     * @param socket 
     *     socket that is sending remote registration event messages
     * @param topic
     *     the topic to listen for
     * @param filter
     *     the filter to add to the topic
     * @return
     *     the remote registration id for remote events, used to unregister for remote events
     * @throws IOException 
     *     if cannot get output stream due to socket issues
     */
Method send registration message listening for remote message events on the given communication avenue.
Method send registration message listening for remote message events on the given communication avenue .
public static int regRemoteEventMessages(Socket socket, String[] topic, String filter, 
            RemoteTypesGen.LexiconFormat.Enum format) throws 
        IOException
    {
        EventRegistrationRequestData.Builder requestMessage = EventRegistrationRequestData.newBuilder()
                .addAllTopic(Arrays.asList(topic));
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, true);
        if (filter != null)
        {
            requestMessage.setFilter(filter);
        }
        if (format != null)
        {
            requestMessage.setObjectFormat(format);
        }
        TerraHarvestMessage message = TestEventAdminNamespace.createEventAdminMessage(
            EventAdminMessageType.EventRegistrationRequest, requestMessage.build());
        try
        {
            message.writeDelimitedTo(socket.getOutputStream());
        }
        catch (IOException exception)
        {
            fail("Unable to send request to receive remote events" + exception.getMessage());
        }
        int registrationId = -1;
        MessageListener listener = new MessageListener(socket);
        Message messageRcvd = 
            listener.waitForMessage(Namespace.EventAdmin, EventAdminMessageType.EventRegistrationResponse, 1000);
        try
        {
            EventAdminNamespace namespaceResponse = (EventAdminNamespace) messageRcvd;
            assertThat(namespaceResponse.getType(), is(EventAdminMessageType.EventRegistrationResponse));
            EventRegistrationResponseData typeResponse = EventRegistrationResponseData.
                parseFrom(namespaceResponse.getData());
            registrationId = typeResponse.getId();
        }
        catch (IOException exception)
        {
            fail("Unable to parse response to receive remote events" + exception.getMessage());
        }
        return registrationId;
    }
public static int regRemoteEventMessages ( Socket socket , String [ ] topic , String filter , RemoteTypesGen . LexiconFormat . Enum format ) throws IOException { EventRegistrationRequestData . Builder requestMessage = EventRegistrationRequestData . newBuilder ( ) . addAllTopic ( Arrays . asList ( topic ) ) ; requestMessage = RemoteUtils . appendRequiredFields ( requestMessage , true ) ; if ( filter != null ) { requestMessage . setFilter ( filter ) ; } if ( format != null ) { requestMessage . setObjectFormat ( format ) ; } TerraHarvestMessage message = TestEventAdminNamespace . createEventAdminMessage ( EventAdminMessageType . EventRegistrationRequest , requestMessage . build ( ) ) ; try { message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; } catch ( IOException exception ) { fail ( "Unable to send request to receive remote events" + exception . getMessage ( ) ) ; } int registrationId = - 1 ; MessageListener listener = new MessageListener ( socket ) ; Message messageRcvd = listener . waitForMessage ( Namespace . EventAdmin , EventAdminMessageType . EventRegistrationResponse , 1000 ) ; try { EventAdminNamespace namespaceResponse = ( EventAdminNamespace ) messageRcvd ; assertThat ( namespaceResponse . getType ( ) , is ( EventAdminMessageType . EventRegistrationResponse ) ) ; EventRegistrationResponseData typeResponse = EventRegistrationResponseData . parseFrom ( namespaceResponse . getData ( ) ) ; registrationId = typeResponse . getId ( ) ; } catch ( IOException exception ) { fail ( "Unable to parse response to receive remote events" + exception . getMessage ( ) ) ; } return registrationId ; }
Method send registration message listening for remote message events on the given communication avenue.
Method send registration message listening for remote message events on the given communication avenue .
//create registration message //append required fields //append filter if filter was sent //create TH message to send //send out message //used to return reg id //start thread message listener //save the reg id for later deregistration