Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'path' to setCookie #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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