Skip to content
Browse files

Make EventSource transport trigger up and down events.

  • Loading branch information...
1 parent b79d70e commit 39e4f37e46f5d18673cb685603e7f2d2eebe90d9 @jcoglan jcoglan committed Mar 20, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 javascript/transport/event_source.js
View
8 javascript/transport/event_source.js
@@ -6,6 +6,14 @@ Faye.Transport.EventSource = Faye.extend(Faye.Class(Faye.Transport, {
var socket = new EventSource(endpoint + '/' + client.getClientId()),
self = this;
+ socket.onopen = function() {
+ self.trigger('up');
+ };
+
+ socket.onerror = function() {
+ self.trigger('down');
+ };
+
socket.onmessage = function(event) {
self.receive(JSON.parse(event.data));
};

0 comments on commit 39e4f37

Please sign in to comment.
Something went wrong with that request. Please try again.