asynchronous - Trying to implement CFTHREAD...unsuccessfully :( -


i made post cfhttp in cfloop limit? use cfthread regarding making multiple cfhttp requests implemented solution of making xmlhttprequest in js function call cfhttp request file.

i've amended runs on intertval timer seem have issue in i'm allowed host make 3 requests per second although may set interval time every 7 seconds still end timing out because cfhttp requests seem pend , make request @ same time (which means it's taking me through threshold).

i've read ben nadel's posts on using cfthread having absolutely no joy implementing them @ all.

my basic process @ moment is:-

  • index.cfm contains js function uses xmlhttprequest calls playersearch.cfm
  • playersearch.cfm makes cfhttp request.
  • playersearch.cfm loops round response , display current item loop submitting cfhttp request make bid on current item in loop if meets of if conditions.
  • index.cfm keeps making requests every x amount of seconds.

is there way can set cfhttp request make request every x amount of seconds (maybe using sleep function in cfthread?) , how display inside cfthread don't seem able to?

also if able make cfhttp request make request every x amount of seconds better calling directly , keep looping continuously?

any feedback appreciated!

edit:

index.cfm

<script>  var searchtimer = null,     searchinterval = 1000,     startposition = 0;  function startsearch() {     if (searchtimer !== null) return;     searchtimer = setinterval(function () {         startposition = startposition + 16;         var xhr = new xmlhttprequest();         xhr.open("get", "playersearch.cfm?startposition="+startposition, true);         xhr.onload = function (e) {             if (xhr.readystate === 4) {                 if (xhr.status === 200) {                     document.getelementbyid("counter").innerhtml = xhr.response;                 } else {                     // error handling                 }             }         };         xhr.onerror = function (e) {             // error handling         };         xhr.send(null);     }, searchinterval); }  function stopsearch() {     clearinterval(searchtimer);     searchtimer = null }  </script> 

playersearch.cfm

<cfset variables.startposition = url.startposition />  <cfhttp url="https://utas.fut.ea.com/ut/game/fifa13/auctionhouse?type=player" method="post" result="getplayer">     <cfhttpparam type="header" name="accept" value="application/json" />     <cfhttpparam type="header" name="accept-language" value="en-gb" />     <cfhttpparam type="header" name="connection" value="keep-alive" />     <cfhttpparam type="header" name="content-length" value="1" />     <cfhttpparam type="header" name="content-type" value="application/json" />     <cfhttpparam type="header" name="cookie" value="#arguments.cookiestring#">     <cfhttpparam type="header" name="host" value="utas.fut.ea.com" />     <cfhttpparam type="header" name="referer" value="http://cdn.easf.www.easports.com/soccer/static/flash/futfifaultimateteamplugin/fifaultimateteam.swf" />     <cfhttpparam type="header" name="user-agent" value="mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml, gecko) chrome/27.0.1453.110 safari/537.36" />     <cfhttpparam type="header" name="x-http-method-override" value="get" />     <cfhttpparam type="header" name="x-ut-embed-error" value="true" />     <cfhttpparam type="header" name="x-flash-version" value="11,7,700,224" />     <cfhttpparam type="header" name="x-ut-sid" value="#arguments.sessionid#" /> </cfhttp>  <cfif getplayer.statuscode eq "200 ok">     <!--- deserialize returned json can loop round each result --->     <cfset variables.searchresults = deserializejson(getplayer.filecontent) />      <!--- if search results returned --->         <cfset variables.numresults = arraylen(variables.searchresults.auctioninfo) />         <cfset variables.bidsmade = 0 />          <table width="900" cellpadding="0" cellspacing="0">             <tr>                 <th width="100" align="left" class="heading">player name</th>                 <th width="70" align="left" class="heading">rating</th>                 <th width="50" align="left" class="heading">formation</th>                 <th width="80" align="left" class="heading">position</th>                 <th width="80" align="left" class="heading">bid status</th>                 <th width="100" align="left" class="heading">starting price</th>                 <th width="80" align="left" class="heading">bin price</th>                 <th width="80" align="left" class="heading">current bid</th>                 <th width="80" align="left" class="heading">my bid</th>                 <th width="120" align="left" class="heading">ends</th>             </tr>             <cfloop from="1" to="#variables.numresults#" index="i">                   <cfscript>                      // default bid amount                     variables.bidamount = 0;                      // set bid amount                     // if item has buy price , less quick sell value bid amount                     if (variables.searchresults.auctioninfo[i].buynowprice neq 0 , variables.searchresults.auctioninfo[i].buynowprice lt variables.searchresults.auctioninfo[i].itemdata.discardvalue) {                         variables.bidamount = variables.searchresults.auctioninfo[i].buynowprice;                     }                     // else if quick sell value 228,231,235,238,242,245 or 249 bid 200                     else if (listfind("228,231,235,238,242,245,249",variables.searchresults.auctioninfo[i].itemdata.discardvalue) , variables.searchresults.auctioninfo[i].startingbid lte 200 , variables.searchresults.auctioninfo[i].currentbid lt 200) {                         variables.bidamount = 200;                     }                     // else if quick sell value 252,256,259 or 300 bid 250                     else if (listfind("252,256,259,300",variables.searchresults.auctioninfo[i].itemdata.discardvalue) , variables.searchresults.auctioninfo[i].startingbid lte 250 , variables.searchresults.auctioninfo[i].currentbid lt 250) {                         variables.bidamount = 250;                     }                      // current coin total                     variables.getcointotal = application.cfcs.club.getcreditstotal(session.phishingkey,session.sessionkey);                     variables.curcoinsdata = deserializejson(variables.getcointotal.filecontent);                     variables.curcoins = variables.curcoinsdata.credits;                      // if have enough coins in account place bid                     if (structkeyexists(variables,"curcoins") , variables.bidamount neq 0 , variables.bidamount lt variables.curcoins) {                          <cfset variables.biddata = '{ "bid": ' & variables.bidamount & ' }'>                         <cfset variables.biddatalength = len(variables.biddata) />                          <cfhttp url="https://utas.fut.ea.com/ut/game/fifa13/trade/" & variables.searchresults.auctioninfo[i].tradeid & "/bid" method="post" result="makebid">                             <cfhttpparam type="header" name="accept" value="application/json" />                             <cfhttpparam type="header" name="connection" value="keep-alive" />                             <cfhttpparam type="header" name="content-type" value="application/json" />                             <cfhttpparam type="header" name="content-length" value="#variables.biddatalength#" />                             <cfhttpparam type="header" name="host" value="utas.fut.ea.com" />                             <cfhttpparam type="header" name="referer" value="http://cdn.easf.www.easports.com/soccer/static/flash/futfifaultimateteamplugin/fifaultimateteam.swf" />                             <cfhttpparam type="header" name="x-http-method-override" value="put" />                             <cfhttpparam type="header" name="x-ut-sid" value="#session.sessionkey#" />                             <cfhttpparam type="header" name="cookie" value="#session.phishingkey#">                                  <cfhttpparam type="header" name="user-agent" value="mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml, gecko) chrome/27.0.1453.110 safari/537.36" />                             <cfhttpparam type="body" value="#variables.biddata#" />                          </cfhttp>                          variables.bidsmade = variables.bidsmade + 1;                      } else {                          variables.bidamount = 0;                      }                 </cfscript>                 <cfoutput>                     <tr>                         <td align="left">#variables.searchresults.auctioninfo[i].itemdata.assetid#</td>                         <td align="left">                             #variables.searchresults.auctioninfo[i].itemdata.rating#                              <cfif variables.searchresults.auctioninfo[i].itemdata.rareflag eq 0>                                 &nbsp;                             <cfelseif variables.searchresults.auctioninfo[i].itemdata.rareflag eq 1>                                 (rare)                             <cfelse>                                 (something else)                             </cfif>                         </td>                         <td align="left">#variables.searchresults.auctioninfo[i].itemdata.formation#</td>                         <td align="left">#variables.searchresults.auctioninfo[i].itemdata.preferredposition#</td>                         <td align="left">#variables.searchresults.auctioninfo[i].bidstate#</td>                         <td align="left">#variables.searchresults.auctioninfo[i].startingbid#</td>                         <td align="left">#variables.searchresults.auctioninfo[i].buynowprice#</td>                         <td align="left">#variables.searchresults.auctioninfo[i].currentbid#</td>                         <td align="left">#variables.bidamount#</td>                         <td align="left">                             <cfif variables.searchresults.auctioninfo[i].tradestate eq "active">                                 <cfset timeleft = variables.searchresults.auctioninfo[i].expires />                                 <cfset auctionends = dateadd("s",timeleft,now()) />                                 #dateformat(variables.auctionends,"dd/mm/yyyy")# #timeformat(variables.auctionends,"hh:mm:ss")#                             <cfelse>                                 ended                             </cfif>                         </td>                     </tr>                 </cfoutput>             </cfloop>         </table>         <br /><br />bids made: <cfoutput>#variables.bidsmade#</cfoutput> <cfelse><br />     search returned error.     <cfdump var="#getplayer#"> </cfif> 


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -