WebSocket Factory for AngularJS