Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Bart Peperkamp
    @bartpeperkamp
    Hi there, I managed to reconnect the socket session (in case of a server restart/error). The connection is 'open', however, i cannot get messages. Does anybody know what to do?
    Muhammad Aref
    @LeoAref
    I spent around 4 hours to figure out how to write a unit test, and I couldn't
    This is my service:
        function eventsStream (storage, $websocket) {
            const _collection = [];
    
            return {
                /**
                 * @param  {function} callback
                 * @return {object}
                 */
                connect (callback) {
                    // FIXME: we have to redirect to the config state
                    if (storage.get('streamConfig')) {
                        const wsUri = 'ws://localhost:8888/api';
                        const dataStream = $websocket(wsUri);
    
                        dataStream.onMessage(message => {
                            _collection.push(JSON.parse(message.data));
    
                            if (angular.isFunction(callback)) {
                                callback(_collection);
                            }
                        });
                    } else {
                        return 'You have to set the stream configuration.';
                    }
    
                    return {
                        collection: _collection
                    };
                }
            };
        }
    The unit test:
        describe('Unit testing eventsStream service', () => {
            let $websocketBackend,
                eventsStream,
                storage;
    
            beforeEach(module('mcp.gogo.services'));
            beforeEach(angular.mock.module('ngWebSocket', 'ngWebSocketMock'));
    
            beforeEach(inject((_$websocketBackend_, _eventsStream_, _storage_) => {
                $websocketBackend = _$websocketBackend_;
                eventsStream = _eventsStream_;
                storage = _storage_;
    
                $websocketBackend.mock();
                $websocketBackend.expectConnect('ws://localhost:8888/api');
                $websocketBackend.expectSend({data: JSON.stringify({test: true})});
                $websocketBackend.mockSend();
            }));
    
            it('Should passes the collection to the connect callback is the configuration exists', () => {
                storage.set('streamConfig', {});
    
                eventsStream.connect(collection => {
                    console.log(collection);
                });
    
                $websocketBackend.flush();
            });
        });
    Muhammad Aref
    @LeoAref
    any help??
    Muhammad Aref
    @LeoAref
    ??
    @/all
    innovation-stack
    @innovation-stack
    I tried to use AMD (requireJS) to load angular-websocket file, but I get an error stating - Uncaught Error: Script error for "ws"
    I checked the source code of angular-websockets.js file, and seems the code tries to require['ws'] module
    I don't see any existence of 'ws' module. Any help would be appreciated here
    piux
    @piux
    did
    well
    i just tried it and i didnt have any problems
    maybe use cdn?
    piux
    @piux
    how can you open a connection with a different url?
    inside the controller
    peffreycollins
    @peffreycollins
    also having trouble with unit testing with $websocketBackend. I can test the connect successfully, but I want to trigger the onOpen event handler so that I can test that functionality. how can I achieve a mocked successful websocket handshake using the mock library?
    chenhui3344
    @chenhui3344
    Is Ok?
    Ash
    @ashthespy

    Hi all!
    I am trying to make a small webapp, and was wondering what the best practice method was for getting initialization data when the socket makes the first connection? I currently have setup a .factoryto return a collection with a .send method. i,e

    .factory('WebSktData', function ($websocket) {
      <snip snip>
    var methods = {
                    collection: collection,
                     send: function (message) {
                        dataStream.send(JSON.stringify(message));
                    }
                };
    return methods;
    })

    What would be considered the correct way to pass a function to the onOpen and onError from the controller, and not directly in the factory?

    Jeremy Carlsten
    @JeremyCarlsten
    Anyone using this with typescript yet?

    I ask because I'm having issues with getting the typings setup. I've found a typings file for angular-websockets but when I try to compile my ts files I get the following error
    tsconfig.json generated: tsconfig.json

    typings/modules/angular-websocket/index.d.ts(23,22): error TS1110: Type expected.
    typings/modules/angular-websocket/index.d.ts(24,35): error TS1109: Expression expected.
    typings/modules/angular-websocket/index.d.ts(163,1): error TS1128: Declaration or statement expected.

    Steeve
    @WnP
    Hi there
    I'm looking to use angular-websocket but once I've install it and injecting it to my all app my unit test beforeEarch call are not... called, is someone have seen a similar issue?
    Steeve
    @WnP
    my bad, I just forget to add angular-websocket to karma imports
    sorry for the noise :D
    mbw42
    @mbw42
    Ask, angular2-websocket support IPv6 access?
    Ask, angular2-websocket support IPv6 access?
    Saurabh Mishra
    @muditsaurabh
    Hi, can somebody give me pointers for using websocket with angular 4
    {{Wishnu}}
    @V5hnu_twitter
    A general websocket question
    Is there any option to send data to client, without any request from client?
    piux
    @piux
    yes use emit
    websockets is about events
    there are 4 events
    or you can use intervals
    tim1003
    @tim1003
    hi
    Fossil
    @Fossil01
    Guys. Anyone here who can help me with adding a JWT Authorization header to the websocket connection string? There's a PR for it which I have transpiled but I dont know how to add it
    AngularClass/angular-websocket#107
    This is my current string which works on ws servers without needing JWT auth.
        var wsTransactions = $websocket('wss://frontend.smartloxs.io:8090/access/transactions', {
            reconnectIfNotNormalClose: false
        });
    Claudio Pomo
    @scne
    I'm using AngularWebSocket with angular-nvd3. I get a lot of error in console about Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
    How can I solve this?
    meshubh
    @meshubh
    Is https://github.com/afrad/angular2-websocket the best alternate for using websockets in angular 5?
    I was using https://github.com/gdi2290/angular-websocket in Angular 1.x
    samialmorshedi
    @samialmorshedi
    I`m using Angular universal and webpack compiler exactly like docs that angular published. But I faced many errors:
    ERROR Error: NotYetImplemented
    at Document.exports.nyi (webpack-internal:///./node_modules/domino/lib/utils.js:41:9)
    at CookieService.check (webpack-internal:///./node_modules/ngx-cookie-service/cookie-service/cookie.service.js:31:48)
    Could you please help me?
    Mateusz Mydlarz
    @Wisunse
    Hi guys, i try to enter angular-websocket documentation and i cant https://www.omniref.com/github/gdi2290/angular-websocket
    someone can help me?
    how i can say to specific channel?
    Mateusz Mydlarz
    @Wisunse
    ok, i made it
    var params = { channel: "AppearanceChannel", uuid: "" };
    let data = JSON.stringify({ command: "subscribe", identifier: JSON.stringify(params)});
    dataStream.send( data );
    prog20901
    @prog20901
    Websocket or TCP or Push Notification - which is best to create stock mobile apps which updates with live stock updates. ???
    Ayub
    @AyubOpen
    I have a websocket application deployed on google cloud platform and the websocket closes after 30 seconds, tried changing the timeout of backend service but it does not resolve the issue. Any clues pls ?
    zorindev
    @zorindev
    Hello. I am trying to use angular-websocket in a spring boot application and failing to find how does the client subscribe to a certain path that the socket is replying on ? Thanks.