コード例 #1
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (request *DeliverRequest) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, request.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadUUID(reader, &request.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &request.ClusterId, &request.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadString(reader, &request.Service)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadString(reader, &request.Data)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
コード例 #2
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (request *HeloRequest) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, request.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadInt(reader, &request.Version)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadString(reader, &request.Service)
	read += bytesRead
	if err != nil {
		return
	}
	return
}