{
Iterator<TunnelConnection> i = connection.connections.values().iterator();
while (i.hasNext())
{
TunnelConnection cw = i.next();
try
{
if ( cw.tunnel.proxy.getGrid() != proxy.getGrid() )
{
cw.c.destroy();
i.remove();
}
else if ( !cw.tunnel.proxy.isActive() )
{
cw.c.destroy();
i.remove();
}
}
catch (GridAccessException e)
{
// :P
}
}
LinkedList<PartP2PTunnelME> newSides = new LinkedList<PartP2PTunnelME>();
try
{
for (PartP2PTunnelME me : getOutputs())
{
if ( me.proxy.isActive() && connections.connections.get( me.getGridNode() ) == null )
{
newSides.add( me );
}
}
for (PartP2PTunnelME me : newSides)
{
try
{
connections.connections.put( me.getGridNode(),
new TunnelConnection( me, AEApi.instance().createGridConnection( outerProxy.getNode(), me.outerProxy.getNode() ) ) );
}
catch (FailedConnection e)
{
AELog.error( e );
// :(