Skip to content

Commit 35d8f66

Browse files
author
MetinSeylan
committed
revert changes & delete issues folder
1 parent 640dfc0 commit 35d8f66

File tree

7 files changed

+54
-178
lines changed

7 files changed

+54
-178
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<a href="https://github.com/MetinSeylan/Vue-Socket.io/"><img src="https://img.shields.io/github/stars/MetinSeylan/Vue-Socket.io.svg"/></a>
1414
</p>
1515

16-
<p>Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements.<p>
16+
<p>Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements<p>
1717

1818
###### Demo
1919
- <a href="http://metinseylan.com/vuesocketio/" target="_blank">Chat Application</a>
@@ -33,7 +33,6 @@ import Vue from 'vue'
3333
import store from './store'
3434
import App from './App.vue'
3535
import VueSocketIO from 'vue-socket.io'
36-
import SocketIO from "socket.io-client"
3736

3837
Vue.use(new VueSocketIO({
3938
debug: true,
@@ -59,7 +58,6 @@ import Vue from 'vue'
5958
import store from './store'
6059
import App from './App.vue'
6160
import VueSocketIO from 'vue-socket.io'
62-
import SocketIO from "socket.io-client"
6361

6462
const options = { path: '/my-app/' }; //Options object to pass into SocketIO
6563

@@ -88,7 +86,6 @@ connection|String/Socket.io-client|`null`|Required|Websocket server url or socke
8886
vuex.store|Vuex|`null`|Optional|Vuex store instance
8987
vuex.actionPrefix|String|`null`|Optional|Prefix for emitting server side vuex actions
9088
vuex.mutationPrefix|String |`null`|Optional|Prefix for emitting server side vuex mutations
91-
vuex.options.useConnectionNamespace |Boolean|`false`|Optional|Use more than one connection namespace
9289

9390
#### 🌈 Component Level Usage
9491

@@ -149,41 +146,6 @@ export default new Vuex.Store({
149146
})
150147
```
151148

152-
#### 🏆 Connection Namespace
153-
<p>When you need to handle more than one namespaced connection, you need to set the `useConnectionNamespace` property of
154-
the options object to true. What this does is telling the plugin that you are going to be using more than one namespaced connection and you want to put every connection in their own `$socket` key.</p>
155-
156-
``` javascript
157-
import Vue from 'vue'
158-
import store from './store'
159-
import App from './App.vue'
160-
import VueSocketIO from 'vue-socket.io'
161-
162-
Vue.use(new VueSocketIO({
163-
debug: true,
164-
connection: 'http://metinseylan.com:1992/mynamespace',
165-
vuex: {
166-
store,
167-
options: {
168-
useConnectionNamespace: true
169-
}
170-
},
171-
options: { path: "/my-app/" } //Optional options
172-
}))
173-
174-
new Vue({
175-
router,
176-
store,
177-
render: h => h(App)
178-
}).$mount('#app')
179-
```
180-
181-
Then use it like this:
182-
183-
``` javascript
184-
Vue.$socket.mynamespace.emit('emit_method', data)
185-
```
186-
187149
## Stargazers over time
188150

189151
[![Stargazers over time](https://starcharts.herokuapp.com/MetinSeylan/Vue-Socket.io.svg)](https://starcharts.herokuapp.com/MetinSeylan/Vue-Socket.io)

dist/vue-socketio.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-socket.io",
33
"author": "Metin Seylan <metinsyln@gmail.com>",
4-
"version": "3.0.9",
4+
"version": "3.0.10",
55
"description": "socket.io implementation for Vue.js and Vuex",
66
"main": "dist/vue-socketio.js",
77
"scripts": {
@@ -38,8 +38,6 @@
3838
"@babel/preset-env": "^7.1.0",
3939
"babel-loader": "^8.0.4",
4040
"cross-env": "^5.2.0",
41-
"vue": "^2.6.10",
42-
"vuex": "^3.1.1",
4341
"webpack": "^4.23.1",
4442
"webpack-cli": "^3.1.2"
4543
}

src/index.js

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Mixin from "./mixin";
2-
import Logger from "./logger";
3-
import Listener from "./listener";
4-
import Emitter from "./emitter";
5-
import SocketIO from "socket.io-client";
1+
import Mixin from './mixin';
2+
import Logger from './logger';
3+
import Listener from './listener';
4+
import Emitter from './emitter';
5+
import SocketIO from 'socket.io-client';
66

77
export default class VueSocketIO {
88

@@ -17,8 +17,6 @@ export default class VueSocketIO {
1717

1818
Logger.debug = debug;
1919
this.io = this.connect(connection, options);
20-
this.useConnectionNamespace = (options && options.useConnectionNamespace);
21-
this.namespaceName = (options && options.namespaceName);
2220
this.emitter = new Emitter(vuex);
2321
this.listener = new Listener(this.io, this.emitter);
2422

@@ -30,48 +28,40 @@ export default class VueSocketIO {
3028
*/
3129
install(Vue){
3230

33-
const namespace = this.namespaceName || this.io.nsp.replace("/", "");
34-
35-
if (this.useConnectionNamespace) {
36-
if (typeof Vue.prototype.$socket === "object") {
37-
Vue.prototype.$socket = {
38-
...Vue.prototype.$socket,
39-
[namespace]: this.io
40-
};
41-
42-
Vue.prototype.$vueSocketIo = {...Vue.prototype.$vueSocketIo, [namespace]: this};
43-
} else {
44-
Vue.prototype.$socket = {
45-
[namespace]: this.io
46-
};
47-
Vue.prototype.$vueSocketIo = { [namespace]: this};
48-
}
49-
} else {
50-
Vue.prototype.$socket = this.io;
51-
Vue.prototype.$vueSocketIo = this;
52-
}
53-
31+
Vue.prototype.$socket = this.io;
32+
Vue.prototype.$vueSocketIo = this;
5433
Vue.mixin(Mixin);
5534

5635
Logger.info('Vue-Socket.io plugin enabled');
5736

5837
}
5938

60-
/**
61-
* registering SocketIO instance
62-
* @param connection
63-
* @param options
64-
*/
65-
connect(connection, options) {
66-
if (connection && typeof connection === "object") {
67-
Logger.info(`Received socket.io-client instance`);
68-
return connection;
69-
} else if (typeof connection === "string") {
70-
const io = SocketIO(connection, options);
71-
Logger.info(`Received connection string`);
72-
return (this.io = io);
73-
} else {
74-
throw new Error("Unsupported connection type");
39+
40+
/**
41+
* registering SocketIO instance
42+
* @param connection
43+
* @param options
44+
*/
45+
connect(connection, options){
46+
47+
if(connection && typeof connection === 'object'){
48+
49+
Logger.info('Received socket.io-client instance');
50+
51+
return connection;
52+
53+
} else if(typeof connection === 'string'){
54+
55+
Logger.info('Received connection string');
56+
57+
return this.io = SocketIO(connection, options);
58+
59+
} else {
60+
61+
throw new Error('Unsupported connection type');
62+
63+
}
64+
7565
}
76-
}
66+
7767
}

src/mixin.js

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,14 @@ export default {
77

88
if(!this.sockets) this.sockets = {};
99

10-
if (typeof this.$vueSocketIo === 'object') {
11-
for (const namespace of Object.keys(this.$vueSocketIo)) {
12-
this.sockets[namespace] = {
13-
subscribe: (event, callback) => {
14-
this.$vueSocketIo[namespace].emitter.addListener(event, callback, this);
15-
},
16-
unsubscribe: (event) => {
17-
this.$vueSocketIo[namespace].emitter.removeListener(event, this);
18-
}
19-
}
20-
}
21-
} else {
10+
this.sockets.subscribe = (event, callback) => {
2211
this.$vueSocketIo.emitter.addListener(event, callback, this);
12+
};
13+
14+
this.sockets.unsubscribe = (event) => {
2315
this.$vueSocketIo.emitter.removeListener(event, this);
24-
}
16+
};
17+
2518
},
2619

2720
/**
@@ -31,27 +24,14 @@ export default {
3124

3225
if(this.$options.sockets){
3326

34-
if (typeof this.$vueSocketIo === 'object') {
35-
for (const namespace of Object.keys(this.$vueSocketIo)) {
36-
if (this.$options.sockets[namespace]) {
37-
Object.keys(this.$options.sockets[namespace]).forEach(event => {
38-
39-
if(event !== 'subscribe' && event !== 'unsubscribe') {
40-
this.$vueSocketIo[namespace].emitter.addListener(event, this.$options.sockets[namespace][event], this);
41-
}
42-
43-
});
44-
}
27+
Object.keys(this.$options.sockets).forEach(event => {
28+
29+
if(event !== 'subscribe' && event !== 'unsubscribe') {
30+
this.$vueSocketIo.emitter.addListener(event, this.$options.sockets[event], this);
4531
}
46-
} else {
47-
Object.keys(this.$options.sockets).forEach(event => {
48-
49-
if(event !== 'subscribe' && event !== 'unsubscribe') {
50-
this.$vueSocketIo.emitter.addListener(event, this.$options.sockets[event], this);
51-
}
52-
53-
});
54-
}
32+
33+
});
34+
5535
}
5636

5737
},
@@ -63,23 +43,11 @@ export default {
6343

6444
if(this.$options.sockets){
6545

66-
if (typeof this.$vueSocketIo === 'object') {
67-
for (const namespace of Object.keys(this.$vueSocketIo)) {
68-
if (this.$options.sockets[namespace]) {
69-
Object.keys(this.$options.sockets[namespace]).forEach(event => {
46+
Object.keys(this.$options.sockets).forEach(event => {
7047

71-
this.$vueSocketIo[namespace].emitter.removeListener(event, this);
72-
73-
});
74-
}
75-
}
76-
} else {
77-
Object.keys(this.$options.sockets).forEach(event => {
48+
this.$vueSocketIo.emitter.removeListener(event, this);
7849

79-
this.$vueSocketIo.emitter.removeListener(event, this);
80-
81-
});
82-
}
50+
});
8351

8452
}
8553

0 commit comments

Comments
 (0)