added server-side Socket.io logic