我是新來的node.js,我要代替我做了一個應用程序在C#中使用的是Node.js,但節點的異步性質是扔我送行:如何實現這個邏輯與節點JS
我會想做到這一點:
1- Read N files, parse them and fill an array with the values from the files.
2- Then every 30 seconds I need to read the files again and get the latest values in the file, added them to the array.
3- but immediately after step 1 is complete I can start a web server that will receive request from a browser. the server needs to send to the client some values form the array.
所以我需要爲Web服務器的連續循環(初始值加載之後)才能夠回覆到客戶端,並在同一時間,我需要定期刷新陣列
與現有的應用程序,我這樣做:
1- read files , fill array
2- start a thread to server the clients (until app is closed)
3- start a thread to read the files again every N seconds and add new values to array (until app is closed)
我將不勝感激任何想法去了解這一點,謝謝
你可能想看看http://expressjs.com/。 –
尋求幫助糾正企圖代碼在這裏是好的,但要求完整的實現不是。嘗試一些,發佈在你的問題,人們會咬:) –
謝謝你alain,但我不是要求一個完整的實施,只是一些指針,讓我開始,如果這是可能的 – user3196371