Example #1
0
func TestItConstructsNewHandshakers(t *testing.T) {
	h := handshake.With(&handshake.Param{
		Conn: new(bytes.Buffer),
	})

	assert.IsType(t, new(handshake.Handshaker), h)
}
Example #2
0
// Handshake preforms the handshake operation against the connecting client. If
// an error is encountered during any point of the handshake process, it will be
// returned immediately.
//
// If no error is encounterd while handshaking, the chunk reading process will
// begin.
//
// See github.com/WatchBeam/RTMP/handshake for details.
func (c *Client) Handshake() error {
	if err := handshake.With(&handshake.Param{
		Conn: c.Conn,
	}).Handshake(); err != nil {
		return err
	}

	go c.chunks.Recv()

	return nil
}
Example #3
0
func TestItAbortsOnReadErrors(t *testing.T) {
	conn := new(bytes.Buffer)

	initial := new(MockSequence)
	initial.On("Read", conn).Return(errors.New("foo")).Once()

	h := handshake.With(&handshake.Param{
		Conn:    conn,
		Initial: initial,
	})

	assert.Equal(t, "foo", h.Handshake().Error())
	initial.AssertExpectations(t)
}
Example #4
0
func TestItCallsHandshakeReadWrite(t *testing.T) {
	conn := new(bytes.Buffer)

	initial := new(MockSequence)
	initial.On("Read", conn).Return(nil).Once()
	initial.On("WriteTo", conn).Return(nil).Once()
	initial.On("Next").Return(nil).Once()

	h := handshake.With(&handshake.Param{
		Conn:    conn,
		Initial: initial,
	})

	assert.Nil(t, h.Handshake())
	initial.AssertExpectations(t)
}