コード例 #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 (deviceList *DeviceList) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, deviceList.Header())
	read += bytesRead
	if err != nil {
		return
	}
	var length int
	bytesRead, err = encoding.ReadInt(reader, &length)
	read += bytesRead
	if err != nil {
		return
	}
	devices := make([]encoding.Device, length)
	for index := 0; index < length; index++ {
		device := *new(encoding.Device)
		bytesRead, err = encoding.ReadCSUUID(reader, &device.ClusterId, &device.DeviceId)
		read += bytesRead
		if err != nil {
			return
		}
		devices[index] = device
	}
	deviceList.Devices = devices
	return
}
コード例 #3
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
	}
	return
}
コード例 #4
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (reply *HeloReply) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, reply.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadInt(reader, &reply.Version)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadInt(reader, &reply.MaxBatch)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
コード例 #5
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (reply *DeliverReply) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, reply.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadUUID(reader, &reply.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	var rawStatus int
	bytesRead, err = encoding.ReadInt(reader, &rawStatus)
	read += bytesRead
	if err != nil {
		return
	}
	reply.Status = DeliverStatus(rawStatus)
	return
}
コード例 #6
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (connChange *ConnChange) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, connChange.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &connChange.ClusterId, &connChange.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	var rawStatus int
	bytesRead, err = encoding.ReadInt(reader, &rawStatus)
	read += bytesRead
	if err != nil {
		return
	}
	connChange.Status = ConnStatus(rawStatus)
	return
}
コード例 #7
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (request *DeviceChangeRequest) 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.Current.ClusterId, &request.Current.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &request.Previous.ClusterId, &request.Previous.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	return
}