我正在使用websocket libarary来创建一些套接字来将数据传递给我的application.some,在我的代码中我写了下面一行。节点js中的回调函数是以同步方式执行的吗?
connection.on('message', function(message)
{
SetOfInstruction1;
SetOfInstruction2;
});
我的疑问是:SetOfInstruction1和SetOfInstruction2;按顺序执行或以异步方式执行(这意味着setOfInstruction2可以在setOfInstruction1之前执行)。
下面是示例SetOfInstruction1和SetOfInstruction2的:
例SetOfInstruction1
for (i 1 to n)
{
find something1 in something2 array
if something1 found then set found boolean to true else false;
}
示例SetOfInstruction2是
for (i:1 to n)
{
if found =true; and someOtherConditions matches
send message back with true response
else{
//continue
}
}
嘿大卫,你有没有找到一个链接,哪里有正确的同步功能和异步功能列表? – user3522412
官方node.js文档在这里:https://nodejs.org/api/,如果文档没有指定,在堆栈溢出中加上问题。 –
thanx大卫,它的ver帮助 – user3522412