Created
May 2, 2012 22:12
-
-
Save cfjedimaster/2580949 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfsetting requesttimeout="999"> | |
<cfset x = 1> | |
<cfloop condition="x lt 100"> | |
<cfscript> | |
stockList = ["APPL","ADBE","MSFT","GOOG","IBM","WOPR","CAT","DOG"]; | |
/* BORKED! | |
arrayEach(stockList, function(itm) { | |
if(!structKeyExists(application.stocks, itm)) { | |
application.stocks[itm] = { stock:itm, price:randRange(100,120)}; | |
} else { | |
change = randRange(-20,20); | |
application.stocks[itm].price += change; | |
//broadcast the change | |
wsPublish("stockchanges", {stock:itm, change:abs(change), netchange:change}); | |
} | |
}); | |
*/ | |
for(itm in stockList) { | |
if(!structKeyExists(application.stocks, itm)) { | |
application.stocks[itm] = { stock:itm, price:randRange(100,120)}; | |
} else { | |
change = randRange(-20,20); | |
application.stocks[itm].price += change; | |
//broadcast the change | |
wsPublish("stockchanges", {stock:itm, change:abs(change), netchange:change}); | |
} | |
} | |
</cfscript> | |
<cfset wsPublish("stocks", application.stocks)> | |
<cfset sleep(4000)> | |
<cfset x++> | |
</cfloop> | |
<p>Done generating demo content...</p> | |
<!--- | |
<cfdump var="#wsGetSubscribers('stocks')#"> | |
<cfdump var="#wsGetSubscribers('stockchanges')#"> | |
---> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment