xpcom回调js的有关问题

xpcom回调js的问题
之前我发了相关的帖子
http://topic.****.net/u/20100408/09/9c311246-67c3-4681-8216-ce1d2287ebfa.html
现在基本上可以回调了,但我的用例子中的代码,register函数不起作用,
用在function MyComponentTestGo()加如下代码才行

C/C++ code

my_xpcom.addObserver(my_observer, "myTopicID", false);



我想了解下一般的注册语句该怎么写,用例子里的如下方法为何不行
C/C++ code

register: function() 
  {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    const cid = "@mozilla.org/observer-service;1";
    //const cid = "@yoursite.com/MyXPCOM1;1";
    var observerService = Components.classes[cid].getService(Components.interfaces.nsIObserverService);
    observerService.addObserver(this, "myTopicID", false);
  },




------解决方案--------------------
因为你的CMyXPCOM1::NotifyObservers()写的不对,你理解错了。
C/C++ code
nsresult
nsWebShellWindow::NotifyObservers( const nsString &aTopic, const nsString &someData )  {
    nsresult rv = NS_OK;
    // Get observer service.
    nsIObserverService *svc = 0;
    rv = nsServiceManager::GetService( "@mozilla.org/observer-service;1",
                                       NS_GET_IID(nsIObserverService),
                                       (nsISupports**)&svc );
    if ( NS_SUCCEEDED( rv ) && svc ) {
        // Notify observers as instructed; the subject is "this" web shell window.
        nsCAutoString topic; topic.Assign(prefix);
        topic.Append(";");
        topic.AppendWithConversion(aTopic);
        rv = svc->NotifyObservers( (nsIWebShellWindow*)this, topic.get(), someData.get() );
        // Release the service.
        nsServiceManager::ReleaseService( "@mozilla.org/observer-service;1", svc );
    } else {
    }
    return rv;
}

------解决方案--------------------
你注册成功后,C++中用NotifyObservers通知所有的observer,然后对应的js中对应callback等来处理