0.0.8 • Published 4 years ago

forsocket-client v0.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

forsocket-client NPM version

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

@Yuqisen

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago