! This will test RMIF when a new client (C2) starts up on same host:port as a
! previously kill client (C1) on that host:port. The
!
! Test Scenario
!     Start Server 1 (S1)
!     Start Server 2 (S2)
!     Start Client 1 (C1) - opens connection to Server 1
!     Kill Client 1
!     Start Client 2 (C2) - on same host:port as Client 1; open connection to Server 2
!       Client 2 should NOT process messages from uninterested Server 1
!
! Note: For user's with this scenario, they will have to set the requireOpen
!       boolean flag to true to prevent "unknown" remote's packets from getting
!       forwarded onto the macro via /PPT={REQUIREOPEN=TRUE} switch.
!       In this test case, we only enable the requireOpen flag on the client side
!
! <sPort>   - The KNOWN port of the server.  Client uses any available port.
! <timeout> - The timeout (max time) that this test should run before aborting
!
! @author  Neon Ngo
! @bug 1548: RMIF cross talk
! @requires NeXtMidas 2.7.3 (for killing RMIF client 1 instance)
!
startmacro L:sPort[-1] D:timeout[30]
  switch DEBUG         debug        GET DEF=false    SDEF=true
  switch DEBUGSERVER   debugs       GET DEF=^debug   SDEF=true
  switch DEBUGCLIENT   debugc       GET DEF=^debug   SDEF=true
  switch VERBOSE       verbose      GET DEF=false    SDEF=true
  switch VERBOSESERVER verboses     GET DEF=^verbose SDEF=true
  switch VERBOSECLIENT verbosec     GET DEF=^verbose SDEF=true
  switch STATEM        statemachine GET DEF=false    SDEF=true

  timer set

  invoke vercomp nxm.sys.lib.StringUtil.compareVersions("^env.nmversion","2.7.3")
  if vercomp LT 0 then
    info "^reg.main.name: requires NeXtMidas 2.7.3+..........SKIP"
    stop
  endif

  call standardSetup timeout sPort
  pipe on
    %test_rmif_crosstalk_server/id=SERVER/STATEM=^statemachine/DEBUG=^debugs/VERBOSE=^verboses/BG this ^sPort
    %test_rmif_crosstalk_client/id=CLIENT/STATEM=^statemachine/DEBUG=^debugc/VERBOSE=^verbosec/BG this ^sPort
  pipe off

  timer elapse
endmacro

!******************************************************************************!
procedure processMessage m:msg
  if debug then
    say "^reg.main.name: Got message name=^msg.name fid=^msg.fid info=^msg.info data=^msg.data"
  endif

  if false then ! Your message name goes here
    ! Your message(s) processing goes here
  else
    call processStandardMessages
  endif
return

! These are a set of standard procedures
include standard_rmif_procs.mminc
