출처: http://xulfr.org/forums/read.php?5,9541

[résolu]plantage notification

Ecrit par : xulien

Date : le 22/08/2007 à 15h01

Salut, je développe un client riche en Xul. Celui-ci est notifié par un serveur distant du changement de certaines valeurs. Pour cela j'ai un mini serveur soap (XPCOM) dans mon client riche qui écoute les notifications de mon serveur distant. Depuis le code javascript je fournis une fonction à l'XPCOM pour être notifié mais lors de l'appel à cette fonction ca plante je ne comprends pas ! Pourriez vous y jeter un oeil ou si vous avez une autre solution...

code javascript

var listener = 
{
 onNotify: function()
 {
   alert("notify");
 }
};

myXPCOM = Components.classes[[CID].createInstance(Components.interfaces.IClient);
voibResult = myXPCOM.init(listener);
 

idl

[[scriptable, uuid(...)]
interface JSCallback : nsISupports 
{
 void onNotify();
};

[[scriptable, uuid(...)]
interface IServerXpcom : nsISupports
{
 boolean init(in JSCallback aCallback)
}
 

code C++ - .h

class ServerXpcom : public IServerXpcom
{
public:
 NS_DECL_ISUPPORTS
 NS_DECL_ISIMSCLIENT

 ServerXpcom();
 // Méthode appelée lorsque le serveur distant notifie
 void vCallNotify();

private:
 ~ServerXpcom();

protected:
 // fonction de callback des notifications 
 nsCOMPtr<JSCallback> js_callback;
}
 

.cpp

NS_IMETHODIMP ServerXpcom::Init(JSCallback *aCallback, PRBool *_retval)
{
 js_callback = aCallback;

 // par exemple si j'appels notify ici ca fonctionne
 js_callback->onNotify();
  
 return NS_OK;
 

}

void ServerXpcom::vCallNotify()
{
 // Si en revanche je l'appels ici ca plante
 js_callback->onNotify();
};
 

Seuls les utilisateurs enregistrés peuvent écrire dans ce forum.

AND