refactor sockets to extract entity handler and send messages for pending actions