mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
Merge f574194efd
into 640dfc044c
This commit is contained in:
commit
53c99a47c4
3 changed files with 17 additions and 11 deletions
8
dist/vue-socketio.js
vendored
8
dist/vue-socketio.js
vendored
File diff suppressed because one or more lines are too long
|
@ -51,6 +51,7 @@ export default class VueSocketIO {
|
||||||
Vue.prototype.$vueSocketIo = this;
|
Vue.prototype.$vueSocketIo = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$useConnectionNamespace = this.useConnectionNamespace
|
||||||
Vue.mixin(Mixin);
|
Vue.mixin(Mixin);
|
||||||
|
|
||||||
Logger.info('Vue-Socket.io plugin enabled');
|
Logger.info('Vue-Socket.io plugin enabled');
|
||||||
|
@ -75,3 +76,4 @@ export default class VueSocketIO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/mixin.js
12
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 (typeof this.$vueSocketIo === 'object' && this.$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 (typeof this.$vueSocketIo === 'object' && this.$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 => {
|
||||||
|
@ -45,7 +49,6 @@ export default {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Object.keys(this.$options.sockets).forEach(event => {
|
Object.keys(this.$options.sockets).forEach(event => {
|
||||||
|
|
||||||
if(event !== 'subscribe' && event !== 'unsubscribe') {
|
if(event !== 'subscribe' && event !== 'unsubscribe') {
|
||||||
this.$vueSocketIo.emitter.addListener(event, this.$options.sockets[event], this);
|
this.$vueSocketIo.emitter.addListener(event, this.$options.sockets[event], this);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +66,7 @@ export default {
|
||||||
|
|
||||||
if(this.$options.sockets){
|
if(this.$options.sockets){
|
||||||
|
|
||||||
if (typeof this.$vueSocketIo === 'object') {
|
if (typeof this.$vueSocketIo === 'object' && this.$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 => {
|
||||||
|
@ -86,3 +89,4 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue