Calls 'on_connection' function only if object target responds 
to it.