Class: ChannelFactory
- Inherits:
-
Object
- Object
- ChannelFactory
- Defined in:
- lib/cirrocumulus/channels.rb
Overview
Factory to retrieve proper communication channel for two agents.
Class Method Summary collapse
Class Method Details
.retrieve(instance, agent) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/cirrocumulus/channels.rb', line 144 def self.retrieve(instance, agent) if agent.is_a?(LocalIdentifier) ontology_instance = Ontology.query_ontology_instance(agent) if ontology_instance return ThreadChannel.new(Ontology.query_ontology_instance(agent)) else Logger['channels::factory'].warn "Thread-local ontology not found for identifier=%s" % agent.to_s end elsif agent.is_a?(RemoteIdentifier) jabber_client = JabberChannel.query_client(instance.to_s) if jabber_client return NetworkChannel.new(jabber_client, agent.is_a?(WholeOntologyIdentifier) ? nil : agent.to_s) else Logger['channels::factory'].warn "No active Jabber clients." end end Logger['channels::factory'].warn "No suitable channel found for #{agent.to_s} (#{agent.class.name})" nil end |