! This will test the RMIF maximum window setting for RDP (Sending side of link).
!
! @bug 927
! @author  Jay Hallam
!------------------------------------------------------------------------------!
startmacro O:cntrl L:port L:wndwSz[16] L:msgCnt[256] S:host["LOCALHOST"]
  switch DEBUG   debug        GET DEF=false SDEF=true
  switch VERBOSE verbose      GET DEF=false SDEF=true
  switch STATEM  statemachine GET DEF=false SDEF=true

  set reg.cntrl cntrl
  set L:anyAvailablePort -1

  pipe on
    rmif/id=SENDER/ppt={WINDOW=^wndwSz}/msgid=MAIN/STATEM=^statemachine/VERBOSE=^verbose anyAvailablePort
    message FUNC=sendw ID=SENDER NAME="OPEN" DATA={ID=CLIENT,HP="^host:^port"}
  pipe off
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 msg.name eqs "STOP_TEST" then
    rem reg.cntrl ! we put this in manually, now remove it
    pipe stop ! sent by ctrl

  elseif msg.name eqs "START_TEST" then
    do i 0 msgCnt-1
      message FUNC=send ID=CLIENT NAME="SET" INFO=0 DATA={L:INDEX=^i}
    enddo
    message FUNC=send ID=cntrl NAME=CLIENT_DONE INFO=0 DATA={TEST=PASS}

  elseif msg.name eqs "OPENED" then
    message FUNC=send ID=cntrl NAME=CLIENT_STARTED DATA={TEST=PASS}

  elseif msg.name eqs "SET" then
    ! do nothing

  elseif msg.name eqss "CLOSE" then
    ! ignore CLOSE and CLOSED messages

  elseif msg.name eqs "NULL"
    ! ignore

  else
!    warn "^reg.main.name: Unhandled Message: Got message name=^msg.name from ^msg.fid"
    message FUNC=send ID=cntrl NAME=CLIENT_TEST INFO=0 &
            DATA={TEXT="Got unhandled message name=^msg.name",TEST=FALSE}
  endif

return
