Skip to content
Browse files

Emit connection:open and connection:close events from the engine prox…

…y that the backend can use.
  • Loading branch information...
1 parent dd3a1b6 commit d595143e5206966ef528fda0bf8d894c70d6858c @jcoglan jcoglan committed
Showing with 11 additions and 3 deletions.
  1. +6 −2 javascript/engines/proxy.js
  2. +5 −1 lib/faye/engines/proxy.rb
View
8 javascript/engines/proxy.js
@@ -45,13 +45,17 @@ Faye.Engine.Proxy = Faye.Class({
connection: function(clientId, create) {
var conn = this._connections[clientId];
if (conn || !create) return conn;
- return this._connections[clientId] = new Faye.Engine.Connection(this, clientId);
+ this._connections[clientId] = new Faye.Engine.Connection(this, clientId);
+ this.trigger('connection:open', clientId);
+ return this._connections[clientId];
},
closeConnection: function(clientId) {
this.debug('Closing connection for ?', clientId);
var conn = this._connections[clientId];
- if (conn && conn.socket) conn.socket.close();
+ if (!conn) return;
+ if (conn.socket) conn.socket.close();
+ this.trigger('connection:close', clientId);
delete this._connections[clientId];
},
View
6 lib/faye/engines/proxy.rb
@@ -68,12 +68,16 @@ def connection(client_id, create)
conn = @connections[client_id]
return conn if conn or not create
@connections[client_id] = Connection.new(self, client_id)
+ trigger('connection:open', client_id)
+ @connections[client_id]
end
def close_connection(client_id)
debug 'Closing connection for ?', client_id
conn = @connections[client_id]
- conn.socket.close if conn and conn.socket
+ return unless conn
+ conn.socket.close if conn.socket
+ trigger('connection:close', client_id)
@connections.delete(client_id)
end

0 comments on commit d595143

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