Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何在socket.emit中添加回调(new Ack())_Node.js_Angular_Socket.io - Fatal编程技术网

Node.js 如何在socket.emit中添加回调(new Ack())

Node.js 如何在socket.emit中添加回调(new Ack()),node.js,angular,socket.io,Node.js,Angular,Socket.io,我的角锉里有这个 this.socket.emit('message',this.data); 这段代码在我的后端nodejs文件中 socket.on('message', function(data, callback){ console.log("****** OnMessage LOGS ******"); console.log(JSON.stringify(data)); if(JSON.stringify(data) == null){ c

我的角锉里有这个

this.socket.emit('message',this.data);
这段代码在我的后端nodejs文件中

socket.on('message', function(data, callback){
    console.log("****** OnMessage LOGS ******");
    console.log(JSON.stringify(data));
    if(JSON.stringify(data) == null){
        callback(false);
    }else
    { callback(true)}
我的emit是假的,她需要类似于Android中函数new Ack()的东西


这个函数是什么?

您可以将回调作为第三个参数添加到socket.emit方法调用中

socket.emit('message', this.data, function (booleanArg) {
    // Do something with the boolean argument
    // Do something with Ack
});

您可以共享引发的错误吗?TypeError:回调不是函数