MCPcopy Create free account
hub / github.com/OpenPrinting/goipp / NewMessageWithGroups

Function NewMessageWithGroups

message.go:129–174  ·  view source on GitHub ↗

NewMessageWithGroups creates a new message with Groups of attributes. Fields like m.Operation, m.Job. m.Printer... and so on will be properly filled automatically.

(v Version, code Code,
	id uint32, groups Groups)

Source from the content-addressed store, hash-verified

127// Fields like m.Operation, m.Job. m.Printer... and so on will
128// be properly filled automatically.
129func NewMessageWithGroups(v Version, code Code,
130 id uint32, groups Groups) *Message {
131
132 m := &Message{
133 Version: v,
134 Code: code,
135 RequestID: id,
136 Groups: groups,
137 }
138
139 for _, grp := range m.Groups {
140 switch grp.Tag {
141 case TagOperationGroup:
142 m.Operation = append(m.Operation, grp.Attrs...)
143 case TagJobGroup:
144 m.Job = append(m.Job, grp.Attrs...)
145 case TagPrinterGroup:
146 m.Printer = append(m.Printer, grp.Attrs...)
147 case TagUnsupportedGroup:
148 m.Unsupported = append(m.Unsupported, grp.Attrs...)
149 case TagSubscriptionGroup:
150 m.Subscription = append(m.Subscription, grp.Attrs...)
151 case TagEventNotificationGroup:
152 m.EventNotification = append(m.EventNotification,
153 grp.Attrs...)
154 case TagResourceGroup:
155 m.Resource = append(m.Resource, grp.Attrs...)
156 case TagDocumentGroup:
157 m.Document = append(m.Document, grp.Attrs...)
158 case TagSystemGroup:
159 m.System = append(m.System, grp.Attrs...)
160 case TagFuture11Group:
161 m.Future11 = append(m.Future11, grp.Attrs...)
162 case TagFuture12Group:
163 m.Future12 = append(m.Future12, grp.Attrs...)
164 case TagFuture13Group:
165 m.Future13 = append(m.Future13, grp.Attrs...)
166 case TagFuture14Group:
167 m.Future14 = append(m.Future14, grp.Attrs...)
168 case TagFuture15Group:
169 m.Future15 = append(m.Future15, grp.Attrs...)
170 }
171 }
172
173 return m
174}
175
176// Equal checks that two messages are equal
177func (m Message) Equal(m2 Message) bool {

Callers 1

TestNewMessageWithGroupsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestNewMessageWithGroupsFunction · 0.68