open-dis / open-dis-javascript

Javascript implementation of the IEEE-1278.1 Distributed Interactive Simulation (DIS) application protocol v6 and v7
BSD 2-Clause "Simplified" License
11 stars 11 forks source link

Chunk functions are different than ones used throughout the repo #17

Closed adamwrobinson5 closed 1 year ago

adamwrobinson5 commented 1 year ago
  1. I've run into an issue inside SignalPdu.js but it looks like it exists in several other PDUs. Every time I try to decode a SignalPdu, I get the error anX.initFromBinary is not a function. This seems to be because initFromBinary is not the correct function name.

The functions defined on the Chunk object in Chunk.js are initFromBinaryDIS and encodeToBinaryDIS. However, the functions used throughout the repository are just initFromBinary and encodeToBinary.

This code snippet comes from inside the SignalPdu:

for(var idx = 0; idx < this.dataLength; idx++)
 {
     var anX = new dis.Chunk(1);
     anX.initFromBinary(inputStream);
     this.data.push(anX);
 }
  1. Perhaps this should be a separate issue but I'm including it here just in case the issue is with my implementation instead of the library. Inside the encodeToBinary function on the SignalPdu, the line this.data[idx].encodeToBinary(outputStream) continues to break because encodeToBinary doesn't exist on the elements inside this.data. As far as I can tell, this.data is just an array of 8 bit values, not specific DIS objects so I'm not sure why we're calling encodeToBinary on the elements of the array instead of doing something like outputStream.writeByte(this.data[idx]). Can anyone tell me what exactly I should be setting this.data to?
leif81 commented 1 year ago

@adamwrobinson5 are you using PduFactory? If not suggest giving it a try and see if you get the same result.

adamwrobinson5 commented 1 year ago

@leif81 Thanks for the reply! But yeah, I am using the PduFactory. The PduFactory news up a SignalPdu which news up a Chunk. The SignalPdu tries calling initFromBinary on the Chunk but it fails because that function doesn't exist on the Chunk.

crhowell3 commented 1 year ago

@adamwrobinson5 @leif81 I can get a branch and PR out to fix the first issue, but I haven't looked too much into the second issue. I can confirm that the first issue is impacting some things I'm working on as well, so if possible, I'd like to get it patched up and get a release cut to the NPM registry.

leif81 commented 1 year ago

@crhowell3 The v1.3.4 release with this change has been published to NPM, give it a try.