From aac02ac05050e4a7c7f14d14a9ce76580922e616 Mon Sep 17 00:00:00 2001 From: Metin Date: Mon, 9 May 2016 16:07:09 +0300 Subject: [PATCH] okay? --- vue-socketio.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/vue-socketio.js b/vue-socketio.js index 11942b6..bec09b0 100644 --- a/vue-socketio.js +++ b/vue-socketio.js @@ -14,7 +14,11 @@ 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 @@ -41,18 +45,18 @@ Vue.mixin({ created: function () { - var me = this; + var self = this; if (this.$options.hasOwnProperty("sockets")) { socket.on("*", function (emit, data) { - if (me.$options.sockets.hasOwnProperty(emit)) { - me.$options.sockets[emit](data); + if (self.$options.sockets.hasOwnProperty(emit)) { + self.$options.sockets[emit].call(self, data); } }); methods.forEach(function (m) { socket.on(m, function (data) { - if (me.$options.sockets.hasOwnProperty(m)) { - me.$options.sockets[m](data); + if (self.$options.sockets.hasOwnProperty(m)) { + self.$options.sockets[m].call(self, data); } }); });