use of com.orientechnologies.orient.enterprise.channel.OChannel in project orientdb by orientechnologies.
the class ORemoteConnectionPushListener method addListener.
public void addListener(final ORemoteConnectionPool pool, final OChannelBinaryAsynchClient connection, final OStorageRemoteAsynchEventListener listener) {
this.listeners.add(listener);
Set<OChannelBinaryAsynchClient> ans = conns.get(listener);
if (ans == null) {
ans = Collections.synchronizedSet(new HashSet<OChannelBinaryAsynchClient>());
Set<OChannelBinaryAsynchClient> putRet = conns.putIfAbsent(listener, ans);
if (putRet != null)
ans = putRet;
}
if (!ans.contains(connection)) {
ans.add(connection);
connection.registerListener(new OChannelListener() {
@Override
public void onChannelClose(OChannel iChannel) {
Set<OChannelBinaryAsynchClient> all = conns.get(listener);
all.remove(iChannel);
if (all.isEmpty()) {
listener.onEndUsedConnections(pool);
}
connection.unregisterListener(this);
}
});
}
}
Aggregations