mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/RemoteEventRegistration.java
public static int regRemoteEventMessagesAlternavtiveSystem(Socket socket, String[] topic, String filter) throws 
        IOException, InterruptedException
    {
        //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);
        }

        //create TH message to send
        EventAdminNamespace.Builder eventMessageBuilder = EventAdminNamespace.newBuilder().
                setType(EventAdminMessageType.EventRegistrationRequest).
                setData(requestMessage.build().toByteString());
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.
                createAdditionalSystemTerraHarvestMsg(Namespace.EventAdmin, eventMessageBuilder);
        
        try
        {
            //send out message
            thMessage.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, 800);
            
        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 using the defined in the 
     * {@link TerraHarvestMessageHelper#ADDITIONAL_SYSTEM_ID}.
     * 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 using the defined in the
TerraHarvestMessageHelper#ADDITIONAL_SYSTEM_ID.
Method send registration message listening for remote message events using the defined in the TerraHarvestMessageHelper#ADDITIONAL_SYSTEM_ID .
public static int regRemoteEventMessagesAlternavtiveSystem(Socket socket, String[] topic, String filter) throws 
        IOException, InterruptedException
    {
        EventRegistrationRequestData.Builder requestMessage = EventRegistrationRequestData.newBuilder()
                .addAllTopic(Arrays.asList(topic));
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, true);
        if (filter != null)
        {
            requestMessage.setFilter(filter);
        }
        EventAdminNamespace.Builder eventMessageBuilder = EventAdminNamespace.newBuilder().
                setType(EventAdminMessageType.EventRegistrationRequest).
                setData(requestMessage.build().toByteString());
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.
                createAdditionalSystemTerraHarvestMsg(Namespace.EventAdmin, eventMessageBuilder);
        try
        {
            thMessage.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, 800);
        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 regRemoteEventMessagesAlternavtiveSystem ( Socket socket , String [ ] topic , String filter ) throws IOException , InterruptedException { EventRegistrationRequestData . Builder requestMessage = EventRegistrationRequestData . newBuilder ( ) . addAllTopic ( Arrays . asList ( topic ) ) ; requestMessage = RemoteUtils . appendRequiredFields ( requestMessage , true ) ; if ( filter != null ) { requestMessage . setFilter ( filter ) ; } EventAdminNamespace . Builder eventMessageBuilder = EventAdminNamespace . newBuilder ( ) . setType ( EventAdminMessageType . EventRegistrationRequest ) . setData ( requestMessage . build ( ) . toByteString ( ) ) ; TerraHarvestMessage thMessage = TerraHarvestMessageHelper . createAdditionalSystemTerraHarvestMsg ( Namespace . EventAdmin , eventMessageBuilder ) ; try { thMessage . 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 , 800 ) ; 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 using the defined in the
 {@link TerraHarvestMessageHelper#ADDITIONAL_SYSTEM_ID}.
Method send registration message listening for remote message events using the defined in the { @link TerraHarvestMessageHelper#ADDITIONAL_SYSTEM_ID } .
//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