src/main/java/com/io7m/aeron_guide/take4/aeron_messaging/server/AeronMessagingServerDuologue.java
/**
     * Create a new duologue. This will create a new publication and
     * subscription pair using a specific session ID and intended only for a
     * single client at a given address.
     *
     * @param aeron The Aeron instance
     * @param clock A clock used for time-related operations
     * @param exec An executor
     * @param local_address The local address of the server ports
     * @param owner_address The address of the client
     * @param session The session ID
     * @param port_data The data port
     * @param port_control The control port
     *
     * @return A new duologue
     */
Create a new duologue. This will create a new publication and
subscription pair using a specific session ID and intended only for a
single client at a given address.



@return A new duologue
Create a new duologue . This will create a new publication and subscription pair using a specific session ID and intended only for a single client at a given address . @return A new duologue
public static AeronMessagingServerDuologue create(
            final Aeron aeron,
            final Clock clock,
            final AeronMessagingServerExecutorService exec,
            final InetAddress local_address,
            final InetAddress owner_address,
            final int session,
            final int port_data,
            final int port_control) {
        Objects.requireNonNull(aeron, "aeron");
        Objects.requireNonNull(clock, "clock");
        Objects.requireNonNull(exec, "exec");
        Objects.requireNonNull(local_address, "local_address");
        Objects.requireNonNull(owner_address, "owner_address");
        LOG.debug(
                "creating new duologue at {} ({},{}) session {} for {}",
                local_address,
                Integer.valueOf(port_data),
                Integer.valueOf(port_control),
                Integer.toString(session),
                owner_address);
        final Instant initial_expire
                = clock.instant().plus(10L, ChronoUnit.SECONDS);
        final ConcurrentPublication pub
                = AeronChannelsHelper.createPublicationDynamicMDCWithSession(aeron,
                        local_address,
                        port_control,
                        AeronMessagingServer.MAIN_STREAM_ID,
                        session);
        try {
            final AeronMessagingServerDuologue duologue
                    = new AeronMessagingServerDuologue(
                            exec,
                            initial_expire,
                            owner_address,
                            session,
                            port_data,
                            port_control);
            final Subscription sub
                    = AeronChannelsHelper.createSubscriptionWithHandlersAndSession(aeron,
                            local_address,
                            port_data,
                            AeronMessagingServer.MAIN_STREAM_ID,
                            duologue::onClientConnected,
                            duologue::onClientDisconnected,
                            session);
            duologue.setPublicationSubscription(pub, sub);
            return duologue;
        } catch (final Exception e) {
            try {
                pub.close();
            } catch (final Exception pe) {
                e.addSuppressed(pe);
            }
            throw e;
        }
    }
public static AeronMessagingServerDuologue create ( final Aeron aeron , final Clock clock , final AeronMessagingServerExecutorService exec , final InetAddress local_address , final InetAddress owner_address , final int session , final int port_data , final int port_control ) { Objects . requireNonNull ( aeron , "aeron" ) ; Objects . requireNonNull ( clock , "clock" ) ; Objects . requireNonNull ( exec , "exec" ) ; Objects . requireNonNull ( local_address , "local_address" ) ; Objects . requireNonNull ( owner_address , "owner_address" ) ; LOG . debug ( "creating new duologue at {} ({},{}) session {} for {}" , local_address , Integer . valueOf ( port_data ) , Integer . valueOf ( port_control ) , Integer . toString ( session ) , owner_address ) ; final Instant initial_expire = clock . instant ( ) . plus ( 10L , ChronoUnit . SECONDS ) ; final ConcurrentPublication pub = AeronChannelsHelper . createPublicationDynamicMDCWithSession ( aeron , local_address , port_control , AeronMessagingServer . MAIN_STREAM_ID , session ) ; try { final AeronMessagingServerDuologue duologue = new AeronMessagingServerDuologue ( exec , initial_expire , owner_address , session , port_data , port_control ) ; final Subscription sub = AeronChannelsHelper . createSubscriptionWithHandlersAndSession ( aeron , local_address , port_data , AeronMessagingServer . MAIN_STREAM_ID , duologue :: onClientConnected , duologue :: onClientDisconnected , session ) ; duologue . setPublicationSubscription ( pub , sub ) ; return duologue ; } catch ( final Exception e ) { try { pub . close ( ) ; } catch ( final Exception pe ) { e . addSuppressed ( pe ) ; } throw e ; } }
Create a new duologue.
Create a new duologue .