New Stream Methods September 2015

Get the latest news on new features, bug fixes and version updates right here!

New Stream Methods September 2015

Postby rob » Fri Sep 18, 2015 2:35 pm

Hi folks,

Some new methods have been added to IgeEntity to allow easier streaming of data.

streamSectionsPush(sectionName) - Allows you to add a new stream section to the existing list of streaming sections.
streamSectionsPull(sectionName) - Allows you to remove a stream section from the existing list of streaming sections.

streamProperty(propName, propVal) - Allows you to get / set a streaming property for an entity. This allows you to easily stream custom properties for an entity without having to add separate custom sections for your custom values. In order to stream these, make sure you call...

Code: Select all
this.streamSectionsPush('props');


...during your entity init. Here is an excerpt from one of my entities that uses streamProperty:

Code: Select all
var Ship = IgeEntityBox2d.extend({
   classId: 'Ship',

   init: function () {
      IgeEntityBox2d.prototype.init.call(this);

      var self = this;
      
      self._ordinance = {};
      self.streamProperty('thrusting', false);
      self.streamProperty('mining', false);


Then, whenever you want to update a property you just call streamProperty() again with the new value. It will be sent to clients in the next stream tick automatically :) e.g.

Code: Select all
self.streamProperty('thrusting', true);
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: New Stream Methods September 2015

Postby Epsilon » Sun Oct 04, 2015 9:52 pm

Hi Rob

Due to custom format of frames sending through websockets which is comma-delimited data, it looks like we can't transfer data with comma inside of it . Also, I found that we should to split(',') a value of `data` variable inside of streamSectionData() method in order to get processable array of data.

Last notice is only valid for sections which are arrays of data.

Btw, why you don't use nice couple of JSON.stringify() and JSON.parse() to send and receive data? For processing speed reason I guess?
ZX Spectrum fan and game developer in the past. Wanna be game developer in present again.
User avatar
Epsilon
 
Posts: 13
Joined: Sat Sep 26, 2015 9:40 pm
Location: Russian Federation


Return to New Features, Latest Versions & General Updates

Who is online

Users browsing this forum: No registered users and 0 guests
cron