mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
okay?
This commit is contained in:
parent
e9536b6108
commit
aac02ac050
1 changed files with 10 additions and 6 deletions
|
@ -14,7 +14,11 @@
|
||||||
throw new Error("[Vue-Socket.io] cannot locate connection")
|
throw new Error("[Vue-Socket.io] cannot locate connection")
|
||||||
}
|
}
|
||||||
|
|
||||||
var socket = Socketio(connection);
|
if (typeof connection === 'string') {
|
||||||
|
var socket = Socketio(connection);
|
||||||
|
} else if (typeof connection === 'object') {
|
||||||
|
var socket = connection;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wildcard support
|
* Wildcard support
|
||||||
|
@ -41,18 +45,18 @@
|
||||||
|
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
created: function () {
|
created: function () {
|
||||||
var me = this;
|
var self = this;
|
||||||
if (this.$options.hasOwnProperty("sockets")) {
|
if (this.$options.hasOwnProperty("sockets")) {
|
||||||
socket.on("*", function (emit, data) {
|
socket.on("*", function (emit, data) {
|
||||||
if (me.$options.sockets.hasOwnProperty(emit)) {
|
if (self.$options.sockets.hasOwnProperty(emit)) {
|
||||||
me.$options.sockets[emit](data);
|
self.$options.sockets[emit].call(self, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
methods.forEach(function (m) {
|
methods.forEach(function (m) {
|
||||||
socket.on(m, function (data) {
|
socket.on(m, function (data) {
|
||||||
if (me.$options.sockets.hasOwnProperty(m)) {
|
if (self.$options.sockets.hasOwnProperty(m)) {
|
||||||
me.$options.sockets[m](data);
|
self.$options.sockets[m].call(self, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue