コード例 #1
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (reply *HeloReply) WriteTo(writer io.Writer) (written int64, err error) {
	bytesWritten, err := encoding.WriteHeader(writer, reply.Header())
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = encoding.WriteInt(writer, reply.Version)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = encoding.WriteInt(writer, reply.MaxBatch)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
コード例 #2
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (request *HeloRequest) WriteTo(writer io.Writer) (written int64, err error) {
	bytesWritten, err := encoding.WriteHeader(writer, request.Header())
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = encoding.WriteInt(writer, request.Version)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
コード例 #3
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (reply *DeliverReply) WriteTo(writer io.Writer) (written int64, err error) {
	bytesWritten, err := encoding.WriteHeader(writer, reply.Header())
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = encoding.WriteUUID(writer, reply.MessageId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = encoding.WriteInt(writer, int(reply.Status))
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
コード例 #4
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (connChange *ConnChange) WriteTo(writer io.Writer) (written int64, err error) {
	bytesWritten, err := encoding.WriteHeader(writer, connChange.Header())
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = encoding.WriteCSUUID(writer, connChange.ClusterId, connChange.DeviceId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = encoding.WriteInt(writer, int(connChange.Status))
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
コード例 #5
0
ファイル: protocol.go プロジェクト: kitcambridge/hermes
func (deviceList *DeviceList) WriteTo(writer io.Writer) (written int64, err error) {
	bytesWritten, err := encoding.WriteHeader(writer, deviceList.Header())
	written += bytesWritten
	if err != nil {
		return
	}
	length := len(deviceList.Devices)
	bytesWritten, err = encoding.WriteInt(writer, length)
	written += bytesWritten
	if err != nil {
		return
	}
	for _, device := range deviceList.Devices {
		bytesWritten, err = encoding.WriteCSUUID(writer, device.ClusterId, device.DeviceId)
		written += bytesWritten
		if err != nil {
			return
		}
	}
	return
}