0
Başka bir "sınıf" içinde oluşturulan bir işlevi çağırmaya çalışıyorum ve bunu socket.on (...) 'da kullanmak istiyorum, ancak çalışmıyorişlev node js soket kullanarak çağrı
'u görüntülemeye devam eder.Bu işlev bir işlev değildir. Burada
burada bothe Serveur.js ve ZoneCollaborative.js//Serveur.js ful kodudur kod
//calling the function
Serveur.prototype.traitementSurConnection = function(socket) {
var that = this
socket.on('connection', function (creator, typeArtifact,idConteneur, typeConteneur) {
that.addArtifact('momo', 'img', 1,0);
})
};
//the function
ZoneCollaborative.prototype.addArtifact = function(creator, typeArtifact,idConteneur, typeConteneur) {
// calcul d'un nouvel identifiant
var id = this.setIdAr();
console.log(' *** ZC : calcul nouveau IdArtifact = '+id);
// création de l'artifact
var monArtifact = new Artifact(id, creator, typeArtifact, idConteneur,
typeConteneur);
console.log(' *** ZC : creation artifact'+monArtifact.getId());
// ajout à la liste
this.artifacts.push(monArtifact);
console.log(' *** ZC : total artifact ='+ this.artifacts.length);
};
Daha fazla kod için Serveu r oluşturulması ve kullanımı. – dfsq
"Serveur" ve "ZoneCollaborative" prototipi paylaşıyor mu? Bu durumda kodu gönderir misiniz? –
hayır paylaşmıyorlar –