This repository was archived by the owner on Oct 2, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ https://github.com/icebob/vue-websocket/archive/master.zip
15
15
```
16
16
17
17
## Usage
18
- Register the plugin
18
+ Register the plugin, it will connect to ` / `
19
19
``` js
20
20
import VueWebsocket from " vue-websocket" ;
21
21
Vue .use (VueWebsocket);
@@ -38,22 +38,35 @@ Use it in your components:
38
38
export default {
39
39
40
40
methods: {
41
- // Emit the server side
42
- this .$socket .emit (" add" , { a: 5 });
41
+ add () {
42
+ // Emit the server side
43
+ this .$socket .emit (" add" , { a: 5 , b: 3 });
44
+ },
45
+
46
+ get () {
47
+ this .$socket .emit (" get" , { id: 12 }, (response ) => {
48
+ ...
49
+ });
50
+ }
43
51
},
44
52
45
53
socket: {
54
+ // Prefix for event names
46
55
// prefix: "/counter/",
56
+
57
+ // If you set `namespace`, it will create a new socket connection to the namespace instead of `/`
47
58
// namespace: "/counter",
48
59
49
60
events: {
50
61
51
62
// Similar as this.$socket.on("changed", (msg) => { ... });
63
+ // If you set `prefix` to `/counter/`, the event name will be `/counter/changed`
64
+ //
52
65
changed (msg ) {
53
66
console .log (" Something changed: " + msg);
54
67
}
55
68
56
- /*
69
+ /* common socket.io events
57
70
connect() {
58
71
console.log("Websocket connected to " + this.$socket.nsp);
59
72
},
You can’t perform that action at this time.
0 commit comments