Skip to content

Possible AMFDecoder design issue #1

Description

@perceptron8

I'm new to nodejs, so I may be wrong, but It seems to me that there can be some serious design issue with AMFDecoder. My first impression is that it silently assumes blocking io (a habit?).

var amfjs = require("amfjs")
var decoder = new amfjs.AMFDecoder(someKindOfReadableStream)
var value = decoder.decode(amfjs.AMF0) //Decode an AMF0 object

When decoder.decode is called, there may be no data available to reader! It uses pull parsing model, which makes no sense with async io (with streams, obviously, incoming data is "pushed in").

(AMFEncoder, on the other side, should work as expected. It "pushes out" data just when it's available.)

There are (at least) two options: one is to use Buffer instead of Readable. Second is to redesign AMFDecoder - it could emit some event after decoding all data.
The former one seems to be simpler.

If you want some help, let me know!

PS. The tests you wrote also seem to take for granted that data is available when decode is called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions