【发布时间】:2016-02-14 05:05:44
【问题描述】:
我是 node.js 的新手,我想用 node.js 替换我用 C# 制作的应用程序,但是 node 的异步特性让我失望:
我想这样做:
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.
所以我需要网络服务器的连续循环(在加载初始值之后)能够回复客户端,同时我需要定期刷新数组
使用现有的应用程序我这样做:
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)
如果有任何想法,我将不胜感激,谢谢
【问题讨论】:
-
你可能想看看expressjs.com。
-
寻求帮助以纠正尝试的代码在这里很好,但要求完整的实现不是。尝试一些东西,在你的问题中发布它,人们会咬你:)
-
谢谢阿兰,但我并不是要求一个完整的实现,如果可能的话,只是一些让我开始的指针
标签: node.js