You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Vue-Socket.io/README.md

59 lines
1.1 KiB
Markdown

9 years ago
# Vue-Socket.io
socket.io implemantation for vuejs
## Install
``` bash
npm install vue-socket.io --save
```
or
``` bash
bower install vue-socket.io
```
## Usage
``` js
import VueSocketio from 'vue-socket.io'; // for ES6
9 years ago
// var VueSocketio = require('vue-socket.io') // for commonjs
9 years ago
Vue.use(VueSocketio, 'http://socketserver.com:1923'); // Automaticly socket connect from url string
/*
import socketio from 'socket.io-client';
9 years ago
var ioInstance = socketio('http://socketserver.com:1923');
9 years ago
Vue.use(VueSocketio, ioInstance); // bind custom socketio instance
*/
var vm = new Vue({
sockets:{
connect: function(){
console.log('socket connected')
},
customEmit: function(){
console.log('this method fired by socket server. eg: io.emit("customEmit", data)')
}
},
methods: {
clickButton: function(val){
// $socket is socket.io-client instance
this.$socket.emit('emit_method', val);
}
}
})
```
9 years ago
## Example
8 years ago
[Realtime Car Tracker System](http://metinseylan.com/)
[Simple Chat App](http://metinseylan.com/vuesocketio/)
9 years ago
## License
[WTFPL](http://www.wtfpl.net/)