diff -r 03ea3d7ddbe1 -r 277c94533395 front_idill/src/communication/js/client.js --- a/front_idill/src/communication/js/client.js Mon Jul 23 10:52:41 2012 +0200 +++ b/front_idill/src/communication/js/client.js Mon Jul 23 16:59:35 2012 +0200 @@ -1,17 +1,38 @@ +/* +* This file is part of the TraKERS\Front IDILL package. +* +* (c) IRI +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +/* + * Projet : TraKERS + * Module : Front IDILL + * Fichier : client.js + * + * Auteur : alexandre.bastien@iri.centrepompidou.fr + * + * Fonctionnalités : Définit la "classe" client permettant de recevoir les instructions du Middleware, sous forme de sockets (via le serveur WebSocket du Middleware). + */ + /* * Un client est défini par une socket, qui permettra de recevoir les données du server websocket du Middleware. * On accède aussi à la mosaïque. + * Est appelé dans le fichier : + * mosaic > fonction loadParameters. */ -function client(host, port, _mosaic) +function Client(host, port, _mosaic) { - this.socket; + this.socket = null; this.mosaic = _mosaic; this.pointerLeft = false; this.pointerRight = false; this.timePointers = 100; - this.pointerLeftTimeout; - this.pointerRightTimeout; + this.pointerLeftTimeout = null; + this.pointerRightTimeout = null; this.isLeftHanded = false; this.createWebSocket('ws://' + host + ':' + port + '/'); @@ -19,8 +40,10 @@ /* * Création et Initialisation des sockets et listeners permettant d'écouter le server. + * Est appelé dans le fichier : + * client > fonction Client. */ -client.prototype.createWebSocket = function(host) +Client.prototype.createWebSocket = function(host) { var _this = this; @@ -67,8 +90,10 @@ /* * Traite un message reçu du Middleware. + * Est appelé dans le fichier : + * client > fonction createWebSocket. */ -client.prototype.processMsg = function(msg) +Client.prototype.processMsg = function(msg) { if(typeof msg === 'undefined' || typeof msg.data === 'undefined') { @@ -103,7 +128,7 @@ if(!this.mosaic.mouseInteractions && this.mosaic.currentMode != 'NO-USER' && this.mosaic.currentMode.indexOf('INCOMING') == -1) { // console.log('pt'); - this.mosaic.refreshMainPointer(x, y); + this.mosaic.refreshPointers(x, y, true); } // /!\ // @@ -138,7 +163,7 @@ if(!this.mosaic.mouseInteractions && this.mosaic.currentMode != 'NO-USER' && this.mosaic.currentMode.indexOf('INCOMING') == -1) { - this.mosaic.refreshSecondPointer(x, y); + this.mosaic.refreshPointers(x, y, false); } if(!this.mosaic.isSecondPointerDisplayed) @@ -239,7 +264,7 @@ this.mosaic.nextDrawCurveTimeout = setTimeout(function() { _this.mosaic.canDrawNextCurve = true; - }, this.mosaic.config['timeoutNextDrawCurve']); + }, this.mosaic.config.timeoutNextDrawCurve); } } } @@ -271,17 +296,4 @@ this.mosaic.pointersIdleNeedLaunch = true; } // /!\/!\ // -} - -/* - * Permet d'envoyer un message au Middleware (optionnel). -*/ -client.prototype.sendMessage = function(data) -{ - //Si data est un objet, on le change en chaine. - if(typeof data === 'object') - { - data = JSON.stringify(data); - } - this.socket.send(data); } \ No newline at end of file