1. scope
  2. hob

Commits

Rune Halvorsen  committed 30b8b9b

Added message source behaviour to service base

  • Participants
  • Parent commits 6a93837
  • Branches default

Comments (0)

Files changed (1)

File templates/js/js-service-base.mako

View file
   }
   arguments.callee.instance = this;
 
+  MessageMixin.apply(this); // mix in message handler behaviour.
+
   this.on_enable_success = function(){};
   this.on_window_filter_change = function(filter){};
   this.on_quit = function(){};
 
   var _handle_scope_message = function(service, message, command, status, tag)
   {
-    if( !tagManager.handle_message(tag, status, message) )
+    var msg_name = _event_map[service][command], service_obj = _services[service];
+    if (msg_name.indexOf('on') == 0)
     {
-      _services[service][_event_map[service][command]](status, message);
+      service_obj[msg_name](status, message);
+      service_obj.post_message(msg_name.slice(2).toLowerCase(), message);
+    }
+    else if (!tagManager.handle_message(tag, status, message))
+    {
+      service_obj[msg_name](status, message);
     }
   }
 
   var _handle_scope_message_debug = function(service, message, command, status, tag)
   {
     window.debug.log_message(service, message, command, status, tag);
-    if( !tagManager.handle_message(tag, status, message) )
-    {
-      _services[service][_event_map[service][command]](status, message);
-    }
+    _handle_scope_message(service, message, command, status, tag);
   }
 
   // static methods