Skip to content

Commit 378f162

Browse files
committed
feature(client) add socketPath
1 parent 9b74c32 commit 378f162

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

lib/client.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,33 @@ var io, exec, Emitify, loadRemote;
99
global.remedy = new RemedyProto();
1010

1111
function RemedyProto() {
12-
function load(prefix, callback) {
12+
function load(prefix, socketPath, callback) {
1313
if (!callback) {
14-
callback = prefix;
15-
prefix = '/remedy';
14+
if (!socketPath) {
15+
callback = prefix;
16+
prefix = '/spero';
17+
} else {
18+
callback = socketPath;
19+
socketPath = '';
20+
}
1621
}
1722

23+
socketPath += '/socket.io';
24+
1825
loadAll(prefix, function() {
1926
init();
2027

2128
if (typeof callback === 'function')
22-
callback(Remedy(prefix));
29+
callback(Remedy(prefix, socketPath));
2330
});
2431
}
2532

26-
function Remedy(prefix) {
33+
function Remedy(prefix, socketPath) {
2734
if (!(this instanceof Remedy))
28-
return new Remedy(prefix);
35+
return new Remedy(prefix, socketPath);
2936

3037
Emitify.call(this);
31-
this._progress = ProgressProto(prefix, this);
38+
this._progress = ProgressProto(prefix, socketPath, this);
3239
}
3340

3441
function init() {
@@ -139,17 +146,18 @@ var io, exec, Emitify, loadRemote;
139146
});
140147
}
141148

142-
function ProgressProto(room, remedy) {
149+
function ProgressProto(room, socketPath, remedy) {
143150
var socket,
144151
href = getHost(),
145152
FIVE_SECONDS = 5000;
146153

147154
if (!(this instanceof ProgressProto))
148-
return new ProgressProto(room, remedy);
155+
return new ProgressProto(room, socketPath, remedy);
149156

150157
socket = io.connect(href + room, {
151158
'max reconnection attempts' : Math.pow(2, 32),
152-
'reconnection limit' : FIVE_SECONDS
159+
'reconnection limit' : FIVE_SECONDS,
160+
path : socketPath
153161
});
154162

155163
socket.on('err', function(error) {

0 commit comments

Comments
 (0)