!
! This will test sending and receiving to and from an RMIF remote with the
! remote ID (RID) set on a client's OPEN message.
! Note: This only tests the client side of RMIF to use the specified remote ID.
!
! @author  Neon Ngo
! @since   NeXtMidas 2.5.3
!
! <sPort>    - The KNOWN port of the server (since 3.5.0: use -1 for semi-random port between 9900-9999).
!              FYI: RMIF Client side *normally* uses any available port.
! <timeout>  - The timeout (max time) that this test should run before aborting
! <remoteID> - ID to use for remote on client side. DEF=TESTREMOTEID
!
startmacro L:sPort[-1] D:timeout[15] S:remoteID["TESTREMOTEID"]
  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

  call standardSetup timeout sPort
  pipe on
    %test_rmif_open_id_server/id=SERVER/STATEM=^statemachine/DEBUG=^debugs/VERBOSE=^verboses/BG this ^sPort
    %test_rmif_open_id_client/id=CLIENT/STATEM=^statemachine/DEBUG=^debugc/VERBOSE=^verbosec/BG this ^sPort remoteID=^remoteID
  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
