Correct typo in comment.
[stompngo.git] / ack.go
blob279ae8f90367dfcf31e00f7ec9b1cef2b6a9cd53
1 //
2 // Copyright © 2011-2017 Guy M. Allard
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 package stompngo
20 Ack a STOMP MESSAGE.
22 For Stomp 1.0 Headers MUST contain a "message-id" header key.
25 For Stomp 1.1 Headers must contain a "message-id" key and a "subscription"
26 header key.
29 For Stomp 1.2 Headers must contain a unique "id" header key.
31 See the specifications at http://stomp.github.com/ for details.
33 Example:
34 h := stompngo.Headers{stompngo.HK_MESSAGE_ID, "message-id1",
35 "subscription", "d2cbe608b70a54c8e69d951b246999fbc20df694"}
36 e := c.Ack(h)
37 if e != nil {
38 // Do something sane ...
42 func (c *Connection) Ack(h Headers) error {
43 c.log(ACK, "start", h, c.Protocol())
44 if !c.connected {
45 return ECONBAD
47 e := checkHeaders(h, c.Protocol())
48 if e != nil {
49 return e
51 switch c.Protocol() {
52 case SPL_12:
53 if _, ok := h.Contains(HK_ID); !ok {
54 return EREQIDACK
56 case SPL_11:
57 if _, ok := h.Contains(HK_SUBSCRIPTION); !ok {
58 return EREQSUBACK
60 if _, ok := h.Contains(HK_MESSAGE_ID); !ok {
61 return EREQMIDACK
63 default: // SPL_10
64 if _, ok := h.Contains(HK_MESSAGE_ID); !ok {
65 return EREQMIDACK
69 e = c.transmitCommon(ACK, h) // transmitCommon Clones() the headers
70 c.log(ACK, "end", h, c.Protocol())
71 return e