Skip to content

Commit 3fa9e60

Browse files
committed
fix: socket connection refactor
1 parent 803a08a commit 3fa9e60

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/client.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
/*globals CustomEvent, config*/
2-
import CoCreateSocket from "@cocreate/socket-client";
2+
import socket from "@cocreate/socket-client";
33
import CoCreateAction from '@cocreate/actions';
44
import CoCreateRender from '@cocreate/render';
55
import CoCreateElements from '@cocreate/elements';
66

7-
let socketApi = new CoCreateSocket('api');
8-
97
const CoCreateApi = {
108
components: { },
11-
9+
1210
init: function({name, component}) {
1311
this.register(name || component.name, component);
14-
if (!socketApi.sockets.size)
15-
socketApi.create();
12+
if (!socket.sockets.size)
13+
socket.create({prefix: 'api'});
1614
},
1715

1816
register: function(name, component) {
1917
const self = this;
2018
if (typeof this.components[name] === 'undefined') {
2119
this.components[name] = component;
2220

23-
socketApi.listen(name, (data) => {
21+
socket.listen(name, (data) => {
2422
self.__response(name, data);
2523
});
2624

@@ -137,7 +135,7 @@ const CoCreateApi = {
137135
},
138136

139137
send: function(component, action, data) {
140-
socketApi.send(component, {action, data});
138+
socket.send(component, {action, data});
141139
},
142140

143141
render: function(action, data) {

0 commit comments

Comments
 (0)