How to use the primus.connect function in primus

To help you get started, we’ve selected a few primus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular-fullstack / generator-angular-fullstack / templates / app / client / components / socket(ws) / socket.service.js View on Github external
constructor() {
        const primus = Primus.connect();
        primus.plugin('emit', primusEmit);

        primus.on('open', function open() {
           console.log('Connection opened');
        });

        if(process.env.NODE_ENV === 'development') {
            primus.on('data', function message(data) {
                console.log('Socket:', data);
            });
        }

        primus.on('info', data => {
            console.log('info:', data);
        });

primus

Primus is a simple abstraction around real-time frameworks. It allows you to easily switch between different frameworks without any code changes.

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis