Module: CPEE::Message

Defined in:
lib/cpee/message.rb

Class Method Summary collapse

Class Method Details

.send(type, event, cpee, instance, instance_uuid, instance_name, content = {}, backend) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cpee/message.rb', line 19

def self::send(type, event, cpee, instance, instance_uuid, instance_name, content={}, backend)
  topic = ::File::dirname(event)
  name = ::File::basename(event)
  backend.publish(type.to_s + ':' + event,
    instance.to_s + ' ' +
    JSON::generate(
      { 'cpee' => cpee,
        'instance-url' => File.join(cpee,instance.to_s),
        'instance-uuid' => instance_uuid,
        'instance-name' => instance_name,
        'instance' => instance,
        'topic' => topic,
        'type' => type,
        'name' => name,
        'timestamp' =>  Time.now.xmlschema(3),
        'content' => content
      }
    )
  )
end