Skip to content

Commit

Permalink
Fixed intermittent streamProperty streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Irrelon committed Sep 18, 2015
1 parent cf2af51 commit c62581f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions engine/core/IgeEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -3279,11 +3279,11 @@ var IgeEntity = IgeObject.extend({
*/
streamProperty: function (propName, propVal) {
this._streamProperty = this._streamProperty || {};
this._streamPropertyChange = this._streamPropertyChange || {};
//this._streamPropertyChange = this._streamPropertyChange || {};

if (propName !== undefined) {
if (propVal !== undefined) {
this._streamPropertyChange[propName] = this._streamProperty[propName] !== propVal;
//this._streamPropertyChange[propName] = this._streamProperty[propName] !== propVal;
this._streamProperty[propName] = propVal;

return this;
Expand Down Expand Up @@ -3463,7 +3463,8 @@ var IgeEntity = IgeObject.extend({
break;

case 'props':
var newData = {},
var newData,
update = false,
i;

if (data !== undefined) {
Expand All @@ -3478,12 +3479,14 @@ var IgeEntity = IgeObject.extend({
}
}
} else {
newData = {};

for (i in this._streamProperty) {
if (this._streamProperty.hasOwnProperty(i)) {
if (this._streamPropertyChange[i]) {
newData[i] = this._streamProperty;
this._streamPropertyChange[i] = false;
}
//if (this._streamPropertyChange[i]) {
newData[i] = this._streamProperty[i];
//this._streamPropertyChange[i] = false;
//}
}
}

Expand Down

3 comments on commit c62581f

@raldred
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Irrelon what's the reasoning behind this change? The documented behaviour suggests properties are only steamed if they've changed. This seems to change that and just stream everything all of the time which seems rather wasteful.

@Irrelon
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I remember that there was a really good reason to do it though, something about values not streaming when they should be.

Once the data gets built up from the multiple stream sections the final string is checked against the previous one and only sent if different, so there is a larger check at the end of the process.

I know the change came because of something not working in the StarFlight project I was working on. Without this change the stream properties never updated or only updated in certain conditions. I realise that is really non-descript but it was 4 months ago :)

I'm happy to revert this change if it's not fixing a problem for others.

@raldred
Copy link
Collaborator

@raldred raldred commented on c62581f Jan 22, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.