All Projects → lajosbencz → vue-wamp

lajosbencz / vue-wamp

Licence: MIT license
AutobahnJS wrapper library fo Vue.js

Programming Languages

javascript
184084 projects - #8 most used programming language
PHP
23972 projects - #3 most used programming language
Vue
7211 projects
HTML
75241 projects

Projects that are alternatives of or similar to vue-wamp

Autobahn Python
WebSocket and WAMP in Python for Twisted and asyncio
Stars: ✭ 2,305 (+4702.08%)
Mutual labels:  wamp, autobahn
Autobahn Java
WebSocket & WAMP in Java for Android and Java 8
Stars: ✭ 1,467 (+2956.25%)
Mutual labels:  wamp, autobahn
Autobahn Js
WAMP in JavaScript for Browsers and NodeJS
Stars: ✭ 1,345 (+2702.08%)
Mutual labels:  wamp
Autobahn Cpp
WAMP for C++ in Boost/Asio
Stars: ✭ 231 (+381.25%)
Mutual labels:  wamp
Loowy
Lua WAMP client
Stars: ✭ 28 (-41.67%)
Mutual labels:  wamp
Wampy
Websocket RPC and Pub/Sub for Python applications and microservices
Stars: ✭ 115 (+139.58%)
Mutual labels:  wamp
Wampy.js
Simple WAMP (WebSocket Application Messaging Protocol) Javascript implementation
Stars: ✭ 244 (+408.33%)
Mutual labels:  wamp
FoxPHP
一个轻量级的Nginx+PHP8本地开发环境
Stars: ✭ 8 (-83.33%)
Mutual labels:  wamp
WebSocketAndroidClient
Android webSocket client for Ratchet Server
Stars: ✭ 17 (-64.58%)
Mutual labels:  autobahn
Wagon
免安裝可攜的 Laravel 開發環境
Stars: ✭ 189 (+293.75%)
Mutual labels:  wamp
Nexus
Full-feature WAMP v2 router and client written in Go
Stars: ✭ 186 (+287.5%)
Mutual labels:  wamp
Klik Socialmediawebsite
Complete PHP-based Login/Registration system, Profile system, Chat room, Forum system and Blog/Polls/Event Management System.
Stars: ✭ 129 (+168.75%)
Mutual labels:  wamp
python-api
Trading API for Quedex Bitcoin Derivatives Exchange.
Stars: ✭ 20 (-58.33%)
Mutual labels:  autobahn
Enqueue Dev
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro
Stars: ✭ 1,977 (+4018.75%)
Mutual labels:  wamp
kraftfahrstrasse
Typescript implementation of WAMP protocol.
Stars: ✭ 20 (-58.33%)
Mutual labels:  wamp
Rx.wamp
An RX wrapper library for Wamp in the browser and node
Stars: ✭ 37 (-22.92%)
Mutual labels:  wamp
wamp-server
WAMP Basic Profile Router
Stars: ✭ 31 (-35.42%)
Mutual labels:  wamp
ERP
ERP 进存销系统
Stars: ✭ 81 (+68.75%)
Mutual labels:  wamp
Online-Appointment-Booking-System
An Online Appointment Booking System for Retail Chain Clinics with both the User as well as the Admin Side.
Stars: ✭ 95 (+97.92%)
Mutual labels:  wamp
thruway.js
RxJS WAMPv2 Client
Stars: ✭ 28 (-41.67%)
Mutual labels:  wamp

vue-wamp

Autobahn wrapper for Vue, served as a plugin

  • Calls to subscribe, register, publish, call, unsubscribe, unregister are deferred, so that they are executed as soon as the Session object of Autobahn is available
  • Plugin packaging
  • Global, static methods
  • Vue mixin methods
  • Automatic garbage collection for Registration and Subscription objects component-wise when used through option (acknowledge option is forced)

Since v2.0.0:

  • Automatic re-subscribe/register if the connection was lost then re-established (only works with mixin methods and component config)
  • Reactive global state
  • Events

Since v3.0.0:

  • wampIsOpen, wampIsConnected and wampIsRetrying are only available on the $root component, to avoid data pollution. (Events are still emitted on all components)
  • Scrapped bundling, use your own toolchain to transpile to the desired compatibility level
  • Deprecated config options:
    • onopen {function}
    • onclose {function}
    • debug {boolean}
  • New config options:
    • namespace {string}: The namespace for the plugin, default: wamp
    • auto_reestablish {boolean}: Automatically re-registers and re-subscribes after reconnection
    • auto_close_timeout {number}: Will close the WS connection after amount of idle milliseconds
  • Rudimentary TypeScript support

Installation

npm install --save vue-wamp

Configuration

// entry.js
import VueWamp from 'vue-wamp'

Vue.use(VueWamp, {
    url: 'ws://demo.crossbar.io/ws',
    realm: 'realm1',

    // change this in case of naming conflict
    namespace: 'wamp',
    // automatically re-registers and re-subscribes after reconnection (on by default)
    auto_reestablish: true,
    // automatically closes WS connection after amount of idle milliseconds (off by default)
    auto_close_timeout: -1,
});

Global status

<template>
    <div>
        <span v-if="$root.wampIsOpen">Connected</span>
        <span v-else-if="$root.wampIsRetrying">Retrying...</span>
        <span v-else>Disconnected</span>    
    </div>
</template>

Events

export default {
  mounted() {
    this.$on('$wamp.status', ({status, lastStatus, details}) => {});
    this.$on('$wamp.opened', ({status, lastStatus, details}) => {});
    this.$on('$wamp.closed', ({status, lastStatus, details}) => {});
    this.$on('$wamp.retrying', ({status, lastStatus, details}) => {});
    this.$on('$wamp.reconnected', ({status, lastStatus, details}) => {});
  },
}

Usage

// component.vue
<template>
    <div></div>
</template>
<script>
export default {
    data() {
        return {
            someValue: 'foobar'
        };
    },
    watch: {
        someValue(val, old) {
            this.$wamp.publish('some-topic', [], {val, old});
        }
    },
    wamp: {
        subscribe: {
            'some-topic'(args, kwArgs, details) {
                this.someValue = kwArgs.val;
            },
            'another-topic': {
                acknowledge: true,
                handler(args, kwArgs, details) {
                    // do stuff
                }
            }
        },
        register: {
            'some-rpc'(args, kwArgs, details) {
                return args[0] + ' I am useful!';
            },
            'another-rpc': {
                invoke: 'random',
                handler(args, kwArgs, details) {
                    // more stuff
                }
            }
        }
    }
}
</script>

Static methods

Vue.$wamp.subscribe, Vue.$wamp.publish, Vue.$wamp.register, Vue.$wamp.call, Vue.$wamp.unsubscribe, Vue.$wamp.unregister

// main.js
Vue.$wamp.subscribe('some-topic', function(args, kwArgs, details) {
        // context is empty
        console.log(this); // = null
    }, {
    acknowledge: true // option needed for promise
}).then(function(s) {
    console.log('AutobahnJS Subscription object: ', s); 
});

Mixin methods

this.$wamp.subscribe, this.$wamp.publish, this.$wamp.register, this.$wamp.call, this.$wamp.unsubscribe, this.$wamp.unregister

export default {
    data() {
      return {
        foo: 'bar',
      };
    },
    mounted() {
        this.$wamp.subscribe('some-topic', function(args, kwArgs, details) {
            // component context is available
            return this.foo;
        }, {
            acknowledge: true // option needed for promise, automatically added
        }).then(function(s) {
            console.log('AutobahnJS Subscription object: ', s); 
        });
    }
}

Todo

  • Example
  • Tests
  • Vuex integration
  • Re-authentication
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].