传输在控制台日志上关闭

时间:2019-05-29 08:13:04

标签: node.js

我有3条路

//Roads
const signin = io.of('/signin');
const cancelOfferOrDemand = io.of("/cancel");
const disconnect = io.of("/disconnect");

其中的前两个工作正常,并记录了发送的信息。 第三个将我打印为“关闭运输”,而不是我发送的信息内容。为了测试和发送这些数据,我只有一个html文件,在该文件中,我将服务器地址切换到了连接位置并发送了信号。因此,在三种情况下发送的数据相同。

//------------------------------ SIGNIN ---------------------------------------//
signin.on('connection', function (socket, information) {

    const collection = client.db(dbName).collection('UserConnected');


    socket.on('new', async function(information) {
        console.log(information);
    });


});

//----------------------- CANCEL OFFER DEMAND --------------------------------//
cancelOfferOrDemand.on('connection', function (socket, information) {
    socket.on('cancel_demand', async function(information) {
        console.log("information");

    });
});


//------------------------------ DISCONNECT ----------------------------------//
disconnect.on('connection', function (socket, information) {
    socket.on('disconnect', async function (information) {
        console.log(information);
        });
});

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

val dialog = builder.create() dialog.setOnShowListener { nameEditText.requestFocus() val s = ContextCompat.getSystemService(requireContext(), InputMethodManager::class.java) s?.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0) } dialog.setOnDismissListener { val s = ContextCompat.getSystemService(requireContext(), InputMethodManager::class.java) s?.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0) } dialog.show() 中的第二个参数information只能给您3个响应:socket.on('disconnect', function(information) { ... })io server disconnectio client disconnect

您要打印的信息通常是第二个参数。如果要显示第一个,请确保更改名称并检查ping timeout中的引用。您还应该对console.log()connect事件做同样的事情。

Documentation event connect
Documentation event disconnect

相关问题