Giter VIP home page Giter VIP logo

Comments (2)

davidwdan avatar davidwdan commented on July 17, 2024

@pshahid I'm glad you find this project useful.

I can see how it would be useful to allow multiple connections, but I can't think of a way to do that without complicating the API.

You might be able to pull this off with a decorator. I'll play around with this a bit to see if I can come up with something.

from angular-wamp.

davidwdan avatar davidwdan commented on July 17, 2024

@pshahid You can try something like this:

     //Create a new provider called $wamp2 that wraps $wamp
    .provider('$wamp2', function ($wampProvider) {
        var options;
        this.init = function (initOptions) {
            options = initOptions || {};
        };
        this.$get = function ($rootScope, $q, $log) {
            var wp = $wampProvider;
            wp.init(options);
            return wp.$get($rootScope, $q, $log);
        };
    })

     //Configure the $wamp2 service
    .config(function ($wamp2Provider) {
        $wamp2Provider.init({
            url: 'ws://127.0.0.1:8080',
            realm: 'realm1'
        });
    })

    //Start $wamp2
    .run(function ($wamp2) {
        $wamp2.open();
    });

Now you can inject $wamp2 into your controller and use it just like $wamp.

With this setup, the events that get broadcasted will be sent to both services, which will cause some problems, especially during reconnections.

I'm going to see if I can get rid of the events, which will allow you to add as many connections as you'd like, without any issues.

from angular-wamp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.