mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
Merge 9e9404af2c
into 640dfc044c
This commit is contained in:
commit
fc7103e9e1
1 changed files with 10 additions and 6 deletions
10
src/mixin.js
10
src/mixin.js
|
@ -7,7 +7,7 @@ export default {
|
||||||
|
|
||||||
if(!this.sockets) this.sockets = {};
|
if(!this.sockets) this.sockets = {};
|
||||||
|
|
||||||
if (typeof this.$vueSocketIo === 'object') {
|
if (this.$vueSocketIo.useConnectionNamespace) {
|
||||||
for (const namespace of Object.keys(this.$vueSocketIo)) {
|
for (const namespace of Object.keys(this.$vueSocketIo)) {
|
||||||
this.sockets[namespace] = {
|
this.sockets[namespace] = {
|
||||||
subscribe: (event, callback) => {
|
subscribe: (event, callback) => {
|
||||||
|
@ -19,8 +19,12 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.sockets.subscribe = (event, callback) => {
|
||||||
this.$vueSocketIo.emitter.addListener(event, callback, this);
|
this.$vueSocketIo.emitter.addListener(event, callback, this);
|
||||||
|
};
|
||||||
|
this.sockets.unsubscribe = (event) => {
|
||||||
this.$vueSocketIo.emitter.removeListener(event, this);
|
this.$vueSocketIo.emitter.removeListener(event, this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,7 +35,7 @@ export default {
|
||||||
|
|
||||||
if(this.$options.sockets){
|
if(this.$options.sockets){
|
||||||
|
|
||||||
if (typeof this.$vueSocketIo === 'object') {
|
if (this.$vueSocketIo.useConnectionNamespace) {
|
||||||
for (const namespace of Object.keys(this.$vueSocketIo)) {
|
for (const namespace of Object.keys(this.$vueSocketIo)) {
|
||||||
if (this.$options.sockets[namespace]) {
|
if (this.$options.sockets[namespace]) {
|
||||||
Object.keys(this.$options.sockets[namespace]).forEach(event => {
|
Object.keys(this.$options.sockets[namespace]).forEach(event => {
|
||||||
|
@ -63,7 +67,7 @@ export default {
|
||||||
|
|
||||||
if(this.$options.sockets){
|
if(this.$options.sockets){
|
||||||
|
|
||||||
if (typeof this.$vueSocketIo === 'object') {
|
if (this.$vueSocketIo.useConnectionNamespace) {
|
||||||
for (const namespace of Object.keys(this.$vueSocketIo)) {
|
for (const namespace of Object.keys(this.$vueSocketIo)) {
|
||||||
if (this.$options.sockets[namespace]) {
|
if (this.$options.sockets[namespace]) {
|
||||||
Object.keys(this.$options.sockets[namespace]).forEach(event => {
|
Object.keys(this.$options.sockets[namespace]).forEach(event => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue