Esempio n. 1
0
func TestMarshallingNonNativeMembers(t *testing.T) {
	buf, err := encoding.Marshal(&struct {
		Foo amf0.Object
	}{*amf0.NewObject()})

	assert.Nil(t, err)
	assert.Equal(t, []byte{0x3, 0x0, 0x0, 0x9}, buf)
}
Esempio n. 2
0
func TestMarshallingPointerTypes(t *testing.T) {
	buf, err := encoding.Marshal(&struct {
		Foo *amf0.Object
	}{amf0.NewObject()})

	assert.Nil(t, err)
	assert.Equal(t, []byte{0x3, 0x0, 0x0, 0x9}, buf)
}
Esempio n. 3
0
func TestNetConnectionReceivablesAreWrittenOut(t *testing.T) {
	chunks := make(chan *chunk.Chunk, 1)
	chunks <- &chunk.Chunk{
		Data: CreateStreamPayload,
	}

	nc := NewNetConnection(chunks, nil)
	go nc.Listen()

	assert.Equal(t, 0, len(nc.Errs()))
	assert.Equal(t, &CreateStreamCommand{
		TransactionId: 4,
		Metadata:      amf0.NewObject(),
	}, <-nc.In())
}
Esempio n. 4
0
// NewStatus returns a new instance of the *Status type.
func NewStatus() *Status {
	return &Status{
		Arguments: *amf0.NewObject(),
	}
}
Esempio n. 5
0
	"github.com/WatchBeam/amf0"
	"github.com/WatchBeam/amf0/encoding"
)

var (
	// DefaultParser is the primary singleton instance of the Parser type.
	// It comes preloaded with all RTMP-related Receivable types, which
	// currently include the connect, createStream, releaseStream, and
	// FCPublish packets.
	//
	// It is recommended that this be used as the primary parcer in any type
	// that requires it.
	DefaultParser Parser = NewParser(map[string]ReceviableFactory{
		"connect": func() Receivable {
			return &ConnectCommand{
				Metadata: amf0.NewObject(),
			}
		},

		"createStream": func() Receivable {
			return &CreateStreamCommand{
				Metadata: amf0.NewObject(),
			}
		},

		"releaseStream": func() Receivable { return new(ReleaseCommand) },

		"FCPublish": func() Receivable { return new(FCPublishCommand) },

		"getStreamLength": func() Receivable {
			return new(GetStreamLength)