A websocket based remote event system

Overview

vue-remote

A websocket based remote event system for Vue.js.

Works with Vue 2.0, untested with Vue 1.0.

Installation

1.) Install package via NPM
npm install vue-remote
2.) Activate plugin within project.
import Vue from 'vue';
import VueRemote from 'vue-remote';

Vue.use(
    VueRemote,
    {
        secure: false,
        host: "localhost",
        port: 8080,
        identifier: 'identifier'
    }
)

or

window.Vue = require('vue');
const VueRemote = require('vue-remote');

Vue.use(
    VueRemote,
    {
        secure: false,
        host: "localhost",
        port: 8080
    }
)

Usage

The Vue.Remote global object.

This plugin provides a direct interface into the websocket client using attach, detach, and emit functions.

The $remote prototype object.

This plugin provides a vm.$remote object with functionally based on Vue's event system with $on, $once, $off, and $emit.


A Note on $emit and emit functions, unlike the normal event system these calls send the information through the client and the server triggers the callback.


The remote component object

This plugin provides a mixin object remote which simplifies the attachment of server events.

Firing an event

There are 2 methods that fire events. They're functionally identical and only differ in name.

...
    this.$remote.$emit('trigger', ...Arguments)

    Vue.Remote.emit('trigger', ...Arguments)
...

The structure used by vue-remote is as follows

// One Argument
// Vue.Remote.emit('trigger', 5)
{
    "identifier": 'trigger',
    "arguments": 5
}

// One Argument which is an object
// Vue.Remote.emit('trigger', { 'data': 5, 'id': 10 })
{
    "identifier": 'trigger',
    "data": 5,
    "id": 10
}

// Two or more Arguments
// Vue.Remote.emit('trigger', 5, 10, 15)
{
    "identifier": 'trigger',
    "arguments": [
        5,
        10,
        15
    ]
}

Listening for an event

There are 3 methods that register event listeners. They're functionally identical and only differ in name.

...
    this.$remote.$on('trigger', function(data) {})
    
    Vue.Remote.attach('trigger', function(data) {}, thisArg)
    
    new Vue({
        remote: {
            trigger: function(data) {
                ...
            }
        }
    })
...

The structure expected by the client is as follows.

{
    "identifier": <identifier>,
    "data": <value to send into the function handler>
}

// example
{
    "identifier": 'trigger',
    "data": {
        "id": 10,
        "foo": "bar"
    }
}

server

vue-remote comes with a basic websocket server script based on the Websocket node package.

Usage

// testServer.js

const Server = require('vue-remote/server');

function messageHandler(message) {
    // message = {
    //    identifier: "trigger",
    //    arguments: [...]
    // }

    ... Handle Message object

    return {
        identifier: "trigger",
        data: "Handled Message"
    };
}

let socketServer = Server( messageHandler, [options]);

use node testServer.js to run the server.

Example

Vue-remote-chat is a quick chat example of the system in action.

License

MIT

You might also like...
Vue.js based REST-ful CRUD system
Vue.js based REST-ful CRUD system

the project is not supported If you want to contribute to this project please fork from this project or email me to add you to what-crud group Vue CRU

A Vue based web server with an integrated API system

Core Server https://www.core-server.io Quick Installation To install Core Server and start a new project, run the following commands: npm install -g c

Browser-based control panel system for OCS, written in Vue 3.

ocs-web Background This is browser-based control panel system for OCS, written in Vue 3. Project setup Run this to fetch all dependencies into the pro

An e-commerce system based on Spring Boot 2.6 and Vue3
An e-commerce system based on Spring Boot 2.6 and Vue3

Jake-mall is an e-commerce system based on Spring Boot 2.6 and Vue3 and related technology stack.

Feather DS - a Vue 3 based design system built around simplicity, consistency, and accessibility

Feather Design System Introduction Feather Design System is a Vue-based design system for creating consistent web UIs that follow best practices for t

Linux System Optimizer and Monitoring - https://oguzhaninan.github.io/Stacer-Web
Linux System Optimizer and Monitoring - https://oguzhaninan.github.io/Stacer-Web

Linux System Optimizer and Monitoring Sponsors Reviews Required Packages curl, systemd PPA Repository (for ubuntu) sudo add-apt-repository ppa:oguzhan

A B/S mode system monitor for linux (demo http://199.247.1.240:2048)
A B/S mode system monitor for linux (demo http://199.247.1.240:2048)

中文说明 sysmon Sysmon is a C/S mode system monitor for Linux distribution. With server side daemon, you can remotely watch usage of your system resources

A Marvelous Open Source Status Page System
A Marvelous Open Source Status Page System

⚠️ WARNING: This the branch for the next planned version (v1): it's unstable and under active development. For the latest stable version, go to the ma

A content management system for voice apps like Alexa Skills and Google Actions
A content management system for voice apps like Alexa Skills and Google Actions

Voice CMS A content management system for voice apps like Alexa Skills and Google Actions. Introduction Setup Features Introduction The goal of this o

Owner
Justin MacArthur
Justin MacArthur
native websocket with vuex integration

vue-native-websocket-es5 · Fork of https://github.com/nathantsoi/vue-native-websocket#readme but without using ES6 Proxy native websocket implementati

null 1 Oct 21, 2022
native websocket with vuex integration

vue-native-websocket native websocket implementation for Vuejs 2 and Vuex Install yarn add vue-native-websocket # or npm install vue-native-websocke

James Leskovar 1 May 10, 2018
Remote control Windows machine from anywhere powered by UltraVNC Server and Piping Server

piping-vnc-server-for-windows Remote control Windows machine from anywhere powered by UltraVNC Server and Piping Server How to use Suppose that Window

Ryo Ota 8 Dec 26, 2022
A restraunt management system app in vue. It has user login system with validation.

Restraunt-Management-System-Vue - A restraunt management system app in vue. It has user login system with validation.

Anisha Gupta 0 Jan 8, 2022
Ticket-system-app - A Ticket System App Using Vue.Js

Ticket System App ?? Description: It is a basic system in which an employee logs

Luis J. Santana 4 Dec 15, 2022
Solar System - Interactive Solar System 3D replica 🪐

Solar System ?? Interactive Solar System 3D replica ?? Try it out! Made with ThreeJS and Vue How does it work? Move around the Solar system with mouse

Jan Pánek 19 Jan 3, 2023
Event Registration Vue.js app with the Python-Django Backend 😎

Events Registration App A cool CRUD Vue app with the Python-Django backend. ??

Raheel Siddiqui 8 Oct 29, 2022
Resources to help you enter, and perhaps win, the Imagine Cup, a worldwide event by Microsoft

Resources to help you enter, and perhaps win, the Imagine Cup, a worldwide event by Microsoft

Microsoft 507 Jan 4, 2023
¡Find talent for your next event

A webapp that will help you to find talent to collaborate as speaker in your event, the data is anonymized and this will help you to focus in the tech and not in who is using this tech.

Quique Fdez Guerra 3 May 6, 2022
SimpleLog - Event tracking all in 1 place! Free & Open Source

Notice. Full stop. This was originally a fun & simple hackathon submission, and a demo for dev to learn about Nuxt3, Supabase, Unocss and other plugin

zernonia 81 Dec 15, 2022