protocol.addStatistic(stat : decoder.Stastic) : Void

Register the Statistic stat with the protocol. Only registered Statistics are passed to the statistic collector.

protocol.addDatafield(df : decoder.Datafield) : Void

Register the Datafield df with the protocol. Only registered Datafields are passed to the next layer or collector when calling dec.nextDecoder().

var dfMarketId  = new decoder.DatafieldUInt("script_v8.market_id")
decoder.protocol.addDatafield(dfMarketId)

protocol.getDatafield(dfName : String) : decoder.Datafield

This method is used to retrieve a Datafield from another layer below the current decoder with the name dfName. The Datafield can then be modified by the current layer and the changes will be reflected when the Datafield reaches the collector.

This method should only be called in the main script body so that it is run at protocol creation time. If used within callbacks, or a Datafield with the requested is name is not defined, this method will return the JavaScript "null" object.

var dfMarketId  = decoder.protocol.getDatafield("script_v8.market_id")
 
function on_data(dec) {
  // after on_data it can be assumed the Datafield may have been set by the preceding layer.
  if (dfMarketId instanceof decoder.DatafieldString) {
    dfMarketId.append("456")
    console.log(dfMarketId.get())
  }
}