Socket io not listening to events
I’m using node.js and socket.io v4.8.0. I’m trying to create a basic chat application that updates my postgress db once an event such as “send message” has been called. I am able to establish a connection. However whenever I try to listen to an event the callback function is never triggered.
Event handling for encapsulated socket.io server
I (js beginner) am creating a node.js webapp with socket.io. I encapsulated my socket server and namespaces to a single module that I call socketManager.js because I heard that this is generally good practice. This module handles everything sockets for my backend like initialization and exports of series of functions to provide limited access to socket functionality. This works great when I want the server to emit an event in particular. However, I have found that while dealing with events originate in socketManager (client event emissions) I cannot access other files or invoke their functionality. I cannot import custom modules into socketManger as most of them import socketManger – and doing so would result in dependency errors. Is there a way to accomplish this, or am I taking the wrong approach?