refactor client socket code into angular service