0.0.8 • Published 6 years ago
forsocket-client v0.0.8
forsocket-client 
The websocket client base on socketjs and stomp.
Installation
You can either install this package with npm, or manually by downloading the primary plugin file.
Usage
Register the plugin. By default, it will connect to /:
import ForSocketClient from 'forsocket-client';
Vue.use(ForSocketClient);Or to connect to another address:
Vue.use(ForSocketClient, {
url: "ws://otherserver:8080", // Spring SocketJS Endpoint.
topic: '/topic', // The subscribe path for all of system user.
user: '/user/' // The subscribe path for myself.
});To use it in your components:
<script>
export default {
mounted () {
this.$forsocket.connect(
topic => {
// TODO All user message received.
}, user => {
// TODO myself message received.
}, error => {
// TODO Connection error!
});
},
methods: {
sendSocketMessage() {
// Send Message to server.
this.$forsocket.send('/app/xxx', JSON.stringify(msg));
}
}
};
</script>License
forsocket-client is available under the MIT license.
Contact
Copyright © 2019 Yuqisen