Maybe I'm being too nice a guy, but here's a script I'm using to 
communicate to a server asynchly, queuing up 4 things to track as well as 
flagging an important 'call' and waiting for that one too.

On the whole you can use most of it, but I'm calling it up by the global 
'gcomlink', and sending it info as a list (ie 
gComlink.sendInfo([#msgID:"0004", #screenduration: 0039, #sessionID: 
0038]), etc. Based on the msgID it does differnet things..


global gSendURL, gQuestionList
property pWaitingList, pDispatchedList, pSwitch, pTempList
property pRespondID

on new me
  pWaitingList = []
  pDispatchedList = []
  pTempList=[:]
  pRespondID = 0
  pSwitch = false
  add(the actorList, me)
  return me
end new me


on sendInfo me, tListToSend
  case tListToSend.MsgID of
    "001":                -- login message
      createSession(me, tListToSend)
    "002", "003", "007":  -- user tracking messages
      append(pWaitingList, tListToSend)
    "004":                -- requesting exam
      requestExam(me, tListToSend)
    "005":                -- exiting / dropping connection messages
      exitSession(me, tListToSend)
  end case
end sendInfo me



on stepFrame me
  if not(pDispatchedList.count) then
    if not(pWaitingList.count) then
      pSwitch = false
    else
      grabWaitingTrackingInfo(me)
    end if
  else
    checkCommunicationStatus(me)
  end if
end stepFrame me


on requestExam me, tListToSend
  pRespondID = postNetText (gSendURL & URLEncode(tListToSend), "")
  append(pDispatchedList, pRespondID)
end requestExam me




on grabWaitingTrackingInfo me
  repeat with index = 1 to 4 
    if index > pWaitinglist.count then exit repeat
    tNetID = postNetText( gSendURL & URLEncode(pWaitingList[index]), "")
    -- adds temp placeholder of tNetID and waiting track info in case of 
error
    addProp(pTempList, tNetID, pWaitingList[index])
    append(pDispatchedList,tNetID)
  end repeat
  repeat with newIndex = (index -1 ) down to 1
    deleteAt(pWaitingList, newIndex)
  end repeat
end grabWaitingTrackingInfo me 



---------------------------------------------------------------------------
-------------------
-- if there are messages being sent, this makes sure the server 
communication returns no error
-- and deletes the instance of that tracking information from it's memory 
or else it displays
-- server commuication error properly
---------------------------------------------------------------------------
-------------------
on checkCommunicationStatus me
  repeat with index = (pDispatchedList.count) down to 1
    if netDone(pDispatchedList[index]) then 
      -- checking if this netID has response information. This is not 
handling errors as yet
      if (pDispatchedList[index] = pRespondID) then
        gQuestionList=value(netTextResult(pDispatchedList[index]))
        pRespondID = 0
      else
        case netError(pDispatchedList[index]) of
          "OK", 0:                           -- message returned ok
            pTempList.deleteProp(pDispatchedList[index])
            pDispatchedList.deleteAt(index)
          4150, 4157, 4154, 4144:            -- failed network messages
            append(pWaitingList, 
pTempList.getAProp(pDispatchedList[index]))
            pTempList.deleteProp(pDispatchedList[index])
            pDispatchedList.deleteAt(index)
          otherwise
            -- temp error tracking 
            put "error" && netError(pDispatchedList[index])
        end case
      end if
    end if
  end repeat
end checkCommunicationStatus me


---------------------------------------------------------------------------
-------------------
--    removing itself from memory (doing it on app quit)
---------------------------------------------------------------------------
-------------------
on kill me
  deleteone(the actorList, me)
end kill me


--------------------[    http://www.grimmWERKS.com   ]------------------
 [ graphic design -|- sound design -|- shockwave -|- lingo -|- cdrom  ]
             


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to