Implemented backend code for socket.io