1.1.0 • Published 2 years ago

socket.io-vuewrapper v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

socket.io-vuewrapper

Contributors Forks Stargazers Issues

Other versions support outdated dependencies, no longer receive updates or do not respond to pull requests, which is why socket.io-vuewrapper was created.

Parts of this REPO were used, so thanks to David Gurshumov and Metin Seylan.

🚀 Installation

npm i socket.io-vuewrapper --save

Example

src/main.js

import { createApp } from 'vue';
import App from './App.vue';
import VueSocketIO from 'socket.io-vuewrapper';

const vSocket = new VueSocketIO({
    debug: true,
    connection: 'http://localhost:8000'
});

createApp(App).use(vSocket).mount('#app')
ParametersType'sDefaultRequiredDescription
debugBooleanfalseOptionalEnable logging for debug
connectionString/Socket.io-clientnullRequiredWebsocket server url or socket.io-client instance

src/App.vue

...
<script>
export default {
  mounted() {
    // Check if you are connected to the server
    if (this.$socket.connected) {
      // Send an object to the connected server
      this.$socket.emit('test', { message: "example" });
    }
  },
  sockets: {
    // Listen for the custom `test` event
    test: function(msg) {
      console.log(msg);
    }
  }
}
</script>
...
1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago