client/js/comm/transporter/transporter.js in rsence-pre-3.0.0.8 vs client/js/comm/transporter/transporter.js in rsence-pre-3.0.0.9
- old
+ new
@@ -13,11 +13,11 @@
**
** Don't call any of its methods from your code.
***/
//var//RSence.COMM
COMM.Transporter = HApplication.extend({
-
+
/** Sets up the default settings upon construction.
**/
constructor: function(){
var _this = this;
_this._detectNativeJSONSupport();
@@ -40,78 +40,86 @@
if((typeof _JSON.parse === _fun) && (typeof _JSON.stringify === _fun)){
this.parseResponseArray = this._nativeParseResponseArray;
}
}
},
-
+
/** Tries to (re)connect to the server as often as possible,
* mandated essentially by the priority of its
* HApplication instance.
**/
onIdle: function(){
this.sync();
},
-
+
/** (Re)sets the priority of itself, effects how
* frequently +onIdle+ is called.
* Usually set by the server.
**/
poll: function(_pri){
HSystem.reniceApp(this.appId,_pri);
},
-
+
/** Returns the last transaction error of itself. Used by +sync+
* to report js errors to the server.
* If no error, returns an empty string.
**/
// getClientEvalError: function(){
// var _this = COMM.Transporter;
// return _this._clientEvalError?'&err_msg=' +
// COMM.Values._encodeString(_this._clientEvalError):'';
// },
-
+
parseResponseArray: function( _responseText ){
return this.decodeObject( _responseText );
},
-
+
_nativeParseResponseArray: function( _responseText ){
return JSON.parse( _responseText );
},
-
+
setValues: function( _values ){
if(!_values instanceof Object){
console.log("Invalid values block: ", _values );
return;
}
var
i = 0,
+ _value,
+ _valueType,
_valueManager = COMM.Values,
_itemtype,
_valueId,
_valueData;
if(_values['new'] instanceof Array){
for(i=0;i<_values['new'].length;i++){
- _valueId = _values['new'][i][0];
- _valueData = _values['new'][i][1];
- _valueManager.create( _valueId, _valueData );
+ _value = _values['new'][i];
+ _valueId = _value[0];
+ _valueData = _value[1];
+ _valueType = 0;
+ if( _value.length === 3 ){
+ _valueType = _value[2];
+ }
+ _valueManager.create( _valueId, _valueData, _valueType );
}
}
if(_values.set instanceof Array){
for(i=0;i<_values.set.length;i++){
- _valueId = _values.set[i][0];
- _valueData = _values.set[i][1];
+ _value = _values.set[i];
+ _valueId = _value[0];
+ _valueData = _value[1];
_valueManager.s( _valueId, _valueData );
}
}
if(_values.del instanceof Array){
for(i=0;i<_values.del.length;i++){
_valueId = _values.del[i];
_valueManager.del( _valueId );
}
}
},
-
+
/** = Description
* Handles synchronization responses.
*
* Upon a successful request, this method is called by
* the onSuccess event of the XMLHttpRequest.
@@ -167,11 +175,11 @@
if(_this._serverInterruptView && _sesKey !== '' ){
_this._serverInterruptView.die();
_this._serverInterruptView = false;
}
},
-
+
/** Sets the +busy+ flag to false and resynchronizes immediately,
* if COMM.Values contain any unsynchronized values.
**/
flushBusy: function(){
var _this = COMM.Transporter;
@@ -292,11 +300,11 @@
}
if( _customColor !== undefined ){
_this._serverInterruptView._setCustomColor(_customColor);
}
},
-
+
/** Called by the XMLHttpRequest, when there was a failure in communication.
**/
failure: function(_resp){
var _this = COMM.Transporter;
// server didn't respond, likely network issue.. retry.
@@ -306,10 +314,10 @@
}
else {
_this.failMessage('Transporter Error','Transporter was unable to complete the synchronization request.');
}
},
-
+
/** Starts requests.
**/
sync: function(){
if(this.stop){
// console.log('sync stop');