You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the way functions are declared on a global variable 'dis', it makes it fairly difficult to use both DIS 6 and DIS 7 in the same module. We have a need to support both versions and potentially DIS 8 when it comes along. Instead of declaring everything to one variable 'dis', could each version assign it to 'disX' where 'X' is the version number?
Example of issue:
constdis6=require('open-dis')// don't need relative import because module 'main' points to dis6.min.jsconstdis7=require("../../../../node_modules/open-dis/dist/dis7.min.js");// overwrites all 'dis' functions to dis7 versionvarentityStatePdu_dis6=newdis6.EntityStatePdu();entityStatePdu_dis6.entityID.entity=1;varentityStatePdu_dis7=newdis7.EntityStatePdu();entityStatePdu_dis6.entityID.entityID=1;varab=newArrayBuffer(1500);varoutputstream=newdis.OutputStream(ab)entityStatePdu_dis6.encodeToBinary(outputStream)// would encode pdu.entityID.entityID instead of pdu.entityID.entityentityStatePdu_dis7.encodeToBinary(outputStream)// encodes pdu.entityID.entityID as expected
A way I got around this was to reset the global dis.EntityID function before any pdu creation but this would get very unwieldy for a more complex pdu.
constdis6=require('open-dis');constdis7=require("../../../../node_modules/open-dis/dist/dis7.min.js");varpdu;// dummy variable for example, would be an dis.Pdu objectif(pdu.protocolVersion==7){global.dis.EntityID=dis7.EntityID;pdu=newdis7.EntityStatePdu();}else{global.dis.EntityID=dis6.EntityID;pdu=newdis6.EntityStatePdu();}
Would definitely appreciate any advice if there is a better way to get around this!
The text was updated successfully, but these errors were encountered:
With the way functions are declared on a global variable 'dis', it makes it fairly difficult to use both DIS 6 and DIS 7 in the same module. We have a need to support both versions and potentially DIS 8 when it comes along. Instead of declaring everything to one variable 'dis', could each version assign it to 'disX' where 'X' is the version number?
Example of issue:
A way I got around this was to reset the global dis.EntityID function before any pdu creation but this would get very unwieldy for a more complex pdu.
Would definitely appreciate any advice if there is a better way to get around this!
The text was updated successfully, but these errors were encountered: