'NodeJs: Socket.io use() method

I can't find any document that make an understanding about use() method. Please explane socket.use() method.

Thanks a lot



Solution 1:[1]

socket.use() is basically where you can add middleware functions, which just means that the function passed as the parameter for thesocket.use() function is executed for every piece of info received.

Here's the socket.io docs

https://socket.io/docs/server-api/#socket-use-fn

Solution 2:[2]

socketio.use() method is same like as express_app.use() method , means both are used for passing middleware-functions , where middleware-functions can control/manipulate every upcoming requests/response on the server.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Take-Some-Bytes
Solution 2 Ajay jangid