mirror of
https://github.com/tenrok/vue-native-websocket.git
synced 2026-06-23 04:30:34 +03:00
okay?
This commit is contained in:
+10
-6
@@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user