func (transport *Websocket) Receive() (packet.Packet, error) {
	transport.readLock.Lock()
	defer transport.readLock.Unlock()

	if !transport.running {
		return packet.Packet{}, io.EOF
	}

	_, reader, err := transport.socket.NextReader()

	if err != nil {
		transport.close()

		return packet.Packet{}, io.EOF
	}

	payload, err := transport.codec.Decode(reader)

	if err != nil {
		return packet.Packet{}, err
	}

	count := len(payload)

	if count == 0 {
		return packet.Packet{}, errors.New("empty payload received")
	} else if count > 1 {
		return packet.Packet{}, errors.New("multiple packets received on single websocket frame")
	}

	return payload[0], nil
}
// Receive receives the next packet from the client socket
Receive receives the next packet from the client socket
// Receive receives the next packet from the client socket
func (transport *Websocket) Receive() (packet.Packet, error) {
	transport.readLock.Lock()
	defer transport.readLock.Unlock()
	if !transport.running {
		return packet.Packet{}, io.EOF
	}
	_, reader, err := transport.socket.NextReader()
	if err != nil {
		transport.close()
		return packet.Packet{}, io.EOF
	}
	payload, err := transport.codec.Decode(reader)
	if err != nil {
		return packet.Packet{}, err
	}
	count := len(payload)
	if count == 0 {
		return packet.Packet{}, errors.New("empty payload received")
	} else if count > 1 {
		return packet.Packet{}, errors.New("multiple packets received on single websocket frame")
	}
	return payload[0], nil
}
func ( transport * Websocket ) Receive ( ) ( packet . Packet , error ) { transport . readLock . Lock ( ) defer transport . readLock . Unlock ( ) if ! transport . running { return packet . Packet { } , io . EOF } _ , reader , err := transport . socket . NextReader ( ) if err != nil { transport . close ( ) return packet . Packet { } , io . EOF } payload , err := transport . codec . Decode ( reader ) if err != nil { return packet . Packet { } , err } count := len ( payload ) if count == 0 { return packet . Packet { } , errors . New ( " " ) } else if count > 1 { return packet . Packet { } , errors . New ( " " ) } return payload [ 0 ] , nil }
Receive receives the next packet from the client socket
Receive receives the next packet from the client socket