Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/proto/ewd-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ var EWD;
e.callback(data);
if (e.deleteWhenFinished && data.finished) ev.splice(i,1);
}
},
has: function(type) {
if (events[type] === undefined) { return false }
return events[type].length
}
};

Expand Down Expand Up @@ -147,9 +151,10 @@ var EWD;
if (messageObj.type === 'ewd-register') {
token = messageObj.message.token;

EWD.setCookie = function(name) {
EWD.setCookie = function(name, path) {
name = name || 'ewd-token';
document.cookie = name + "=" + token;
path = path || '/';
document.cookie = name + "=" + token + "; path="+path+";";
};

if (!EWD.jwt) {
Expand Down Expand Up @@ -333,6 +338,11 @@ var EWD;
console.log('*** server has disconnected socket, possibly because it shut down or because token has expired');
EWD.emit('socketDisconnected');
});

socket.on('connect_error', function() {
console.log('*** server cannot create a socket, possibly because it shut down');
EWD.emit('connect_error');
});

}
else {
Expand All @@ -359,6 +369,7 @@ var EWD;
proto.on = emitter.on;
proto.off = emitter.off;
proto.emit = emitter.emit;
proto.has = emitter.has;
proto.start = start;

EWD = new ewd();
Expand Down