コード例 #1
0
// CN writes device ID change request to IR socket.
func (request *DeviceChangeRequest) WriteNodeRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeDeviceChange)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteUUID(writer, request.MessageId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.Current)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.Previous)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteString(writer, request.ServiceName)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
コード例 #2
0
ファイル: handshake.go プロジェクト: kitcambridge/hermes-go
func (request *ConnChange) WriteNodeRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeConnChange)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.DeviceId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteInt(writer, request.Change)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
コード例 #3
0
ファイル: handshake.go プロジェクト: kitcambridge/hermes-go
func (request *DeviceList) WriteNodeRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeDeviceList)
	written += bytesWritten
	if err != nil {
		return
	}
	length := len(request.Devices)
	bytesWritten, err = common.WriteInt(writer, length)
	written += bytesWritten
	if err != nil {
		return
	}
	for _, device := range request.Devices {
		bytesWritten, err = common.WriteDevice(writer, device)
		written += bytesWritten
		if err != nil {
			return
		}
	}
	return
}
コード例 #4
0
ファイル: deliver.go プロジェクト: kitcambridge/hermes-go
// Service writes delivery request to OR socket. Useful for tests and Go
// services.
func (request *DeliverRequest) WriteServiceRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderServiceDeliver)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteUUID(writer, request.MessageId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.DeviceId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteString(writer, request.Data)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}