All Projects → MetinSeylan → Vue Socket.io

MetinSeylan / Vue Socket.io

Licence: mit
😻 Socket.io implementation for Vuejs and Vuex

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Socket.io

Vuex Socketio Plugin
Vuex plugin to integrate socket.io client
Stars: ✭ 34 (-99.09%)
Mutual labels:  websocket, vuex, socket-io
Vue Chat
📲 A web chat application. Vue + node(koa2) + Mysql + socket.io
Stars: ✭ 617 (-83.53%)
Mutual labels:  websocket, vuex, socket-io
Tap Tap Adventure
Tap Tap Adventure is a massively online 2D MMORPG set in the medieval times with twists.
Stars: ✭ 123 (-96.72%)
Mutual labels:  websocket, socket-io
Light Push
轻量级推送服务和实时在线监控平台,同时用于开发即时通信系统,基于node的socket.io,支持web、android、ios客户端,支持移动端离线推送,可进行分布式部署
Stars: ✭ 128 (-96.58%)
Mutual labels:  websocket, socket-io
Flutter socket io
Socket IO supprt for flutter. Looking for contributors Swift and Java.
Stars: ✭ 170 (-95.46%)
Mutual labels:  websocket, socket-io
Webchat
A realtime chat for web
Stars: ✭ 106 (-97.17%)
Mutual labels:  websocket, vuex
Vue Crypto Dashboard
Cryptocurrency Dashboard made with Vue
Stars: ✭ 107 (-97.14%)
Mutual labels:  websocket, vuex
Python Engineio
Python Engine.IO server and client
Stars: ✭ 167 (-95.54%)
Mutual labels:  websocket, socket-io
Tyloo Chat
vue + nestjs IM即时通讯聊天室(仿wechat)
Stars: ✭ 54 (-98.56%)
Mutual labels:  websocket, socket-io
Python Socketio
Python Socket.IO server and client
Stars: ✭ 2,655 (-29.12%)
Mutual labels:  websocket, socket-io
Cuckoo
🎥 Cuckoo - A free anonymous video-calling web application built with WebRTC and React that provides peer-to-peer video and audio communication in a web browser with no plugins or extensions required.
Stars: ✭ 195 (-94.79%)
Mutual labels:  websocket, socket-io
Egg Socket.io
socket.io plugin for eggjs.
Stars: ✭ 209 (-94.42%)
Mutual labels:  websocket, socket-io
Chat Engine
Object oriented event emitter based framework for building chat applications in Javascript.
Stars: ✭ 87 (-97.68%)
Mutual labels:  websocket, socket-io
Laverna
Laverna is a JavaScript note taking application with Markdown editor and encryption support. Consider it like open source alternative to Evernote.
Stars: ✭ 8,770 (+134.12%)
Mutual labels:  websocket, socket-io
Node Multiple Rooms Chat
node socket.io multiple room chat demo
Stars: ✭ 118 (-96.85%)
Mutual labels:  websocket, socket-io
Socketio Examples
A few examples that demonstrate the features of the Python Socket.IO server
Stars: ✭ 72 (-98.08%)
Mutual labels:  websocket, socket-io
Itunes Remote
Remotely control iTunes on Mac without Internet 🎶📱
Stars: ✭ 160 (-95.73%)
Mutual labels:  websocket, socket-io
Vue Project
基于vue-cli构建的财务后台管理系统(vue2+vuex+axios+vue-router+element-ui+echarts+websocket+vue-i18n)
Stars: ✭ 301 (-91.96%)
Mutual labels:  websocket, vuex
Beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps.
Stars: ✭ 1,056 (-71.81%)
Mutual labels:  websocket, socket-io
Wechat
聊天系统、Vue.js、React.js、node.js、MongoDB、websocket、socket.io、前后端分离、毕业设计。
Stars: ✭ 188 (-94.98%)
Mutual labels:  websocket, socket-io

Patreon

Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements.

Demo

You can also check my other npm library Nestjs OpenTelemetry

are you looking for old documentation? it's here

🚀 Installation

npm install vue-socket.io --save
Using Connection String
import Vue from 'vue'
import store from './store'
import App from './App.vue'
import VueSocketIO from 'vue-socket.io'

Vue.use(new VueSocketIO({
    debug: true,
    connection: 'http://metinseylan.com:1992',
    vuex: {
        store,
        actionPrefix: 'SOCKET_',
        mutationPrefix: 'SOCKET_'
    },
    options: { path: "/my-app/" } //Optional options
}))

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
Using socket.io-client Instance
import Vue from 'vue'
import store from './store'
import App from './App.vue'
import VueSocketIO from 'vue-socket.io'
import SocketIO from 'socket.io-client'

const options = { path: '/my-app/' }; //Options object to pass into SocketIO

Vue.use(new VueSocketIO({
    debug: true,
    connection: SocketIO('http://metinseylan.com:1992', options), //options object is Optional
    vuex: {
      store,
      actionPrefix: "SOCKET_",
      mutationPrefix: "SOCKET_"
    }
  })
);

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
Parameters Type's Default Required Description
debug Boolean false Optional Enable logging for debug
connection String/Socket.io-client null Required Websocket server url or socket.io-client instance
vuex.store Vuex null Optional Vuex store instance
vuex.actionPrefix String null Optional Prefix for emitting server side vuex actions
vuex.mutationPrefix String null Optional Prefix for emitting server side vuex mutations

🌈 Component Level Usage

If you want to listen socket events from component side, you need to add `sockets` object in Vue component, and every function will start to listen events, depends on object key

new Vue({
    sockets: {
        connect: function () {
            console.log('socket connected')
        },
        customEmit: function (data) {
            console.log('this method was fired by the socket server. eg: io.emit("customEmit", data)')
        }
    },
    methods: {
        clickButton: function (data) {
            // $socket is socket.io-client instance
            this.$socket.emit('emit_method', data)
        }
    }
})
Dynamic Listeners

If you need consuming events dynamically in runtime, you can use `subscribe` and `unsubscribe` methods in Vue component

this.sockets.subscribe('EVENT_NAME', (data) => {
    this.msg = data.message;
});

this.sockets.unsubscribe('EVENT_NAME');
Defining handlers for events with special characters

If you want to handle 'kebab-case', or "event with space inside it" events, then you have to define it via the following way

export default {
  name: 'Test',
  sockets: {
    connect: function () {
      console.log('socket to notification channel connected')
    },
  },

  data () {
    return {
      something: [
         // ... something here for the data if you need.
      ]
    }
  },

  mounted () {
    this.$socket.subscribe("kebab-case", function(data) {
        console.log("This event was fired by eg. sio.emit('kebab-case')", data)
    })
  }
}

🏆 Vuex Integration

When you set store parameter in installation, `Vue-Socket.io` will start sending events to Vuex store. If you set both prefix for vuex, you can use `actions` and `mutations` at the same time. But, best way to use is just `actions`

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {},
    mutations: {
        "<MUTATION_PREFIX><EVENT_NAME>"() {
            // do something
        }
    },
    actions: {
        "<ACTION_PREFIX><EVENT_NAME>"() {
            // do something
        }
    }
})

Stargazers over time

Stargazers over time

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].