Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tree: 030cc1a8fb
Fetching contributors…

Cannot retrieve contributors at this time

246 lines (209 sloc) 6.333 kb
// Copyright © 2011-2012 Guy M. Allard
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed, an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package stompngo
import (
const (
// Client generated commands.
// Server generated commands.
// Supported STOMP protocol definitions.
SPL_10 = "1.0"
SPL_11 = "1.1"
Protocol slice.
type protocols []string
What this package currently supports.
var supported = protocols{SPL_10, SPL_11}
Headers definition, a slice of string.
STOMP headers are key and value pairs. See the specification for more
information about STOMP frame headers.
Key values are found at even numbered indices. Values
are found at odd numbered incices. Headers are validated for an even
number of slice elements.
type Headers []string
Message is a STOMP Message, consisting of: a STOMP command; a set of STOMP
Headers; and a message body(payload), which is possibly empty.
type Message struct {
Command string
Headers Headers
Body []uint8
Frame is an alternate name for a Message.
type Frame Message
MessageData passed to the client, containing: the Message; and an Error
value which is possibly nil.
Note that this has no relevance on whether a MessageData.Message.Command
value contains an "ERROR" generated by the broker.
type MessageData struct {
Message Message
Error error
This is outbound on the wire.
type wiredata struct {
frame Frame
errchan chan error
Connection is a representation of a STOMP connection.
type Connection struct {
ConnectResponse *Message // Broker response (CONNECTED/ERROR) if physical connection successful.
DisconnectReceipt MessageData // If receipt requested on DISCONNECT.
MessageData <-chan MessageData // Inbound data for the client.
connected bool
session string
protocol string
input chan MessageData
output chan wiredata
netconn net.Conn
subs map[string]chan MessageData
subsLock sync.Mutex
wsd chan bool // writer shutdown
rsd chan bool // reader shutdown
hbd *heartbeat_data
wtr *bufio.Writer
rdr *bufio.Reader
Hbrf bool // Indicates a heart beat read/receive failure, which is possibly transient. Valid for 1.1+ only.
Hbsf bool // Indicates a heart beat send failure, which is possibly transient. Valid for 1.1+ only.
logger *log.Logger
Error definition.
type Error string
Error constants.
const (
// ERROR Frame returned by broker on connect.
ECONERR = Error("broker returned ERROR frame, CONNECT")
// ERRRORs for Headers.
EHDRLEN = Error("unmatched headers, bad length")
EHDRUTF8 = Error("header string not UTF8")
EHDRNIL = Error("headers can not be nil")
// ERRORs for response to CONNECT.
EUNKFRM = Error("unrecognized frame returned, CONNECT")
EUNKHDR = Error("currupt frame headers")
EUNKBDY = Error("corrupt frame body")
// Not connected.
ECONBAD = Error("no current connection")
// Destination required
EREQDSTSND = Error("destination required, SEND")
EREQDSTSUB = Error("destination required, SUBSCRIBE")
EREQDSTUNS = Error("destination required, UNSUBSCRIBE")
// Message ID required.
EREQMIDACK = Error("message-id required, ACK")
// Subscription required (STOMP 1.1).
EREQSUBACK = Error("subscription required, ACK")
// NACK's. STOMP 1.1 or greater.
EREQMIDNAK = Error("message-id required, NACK")
EREQSUBNAK = Error("subscription required, NACK")
// Transaction ID required.
EREQTIDBEG = Error("transaction-id required, BEGIN")
EREQTIDCOM = Error("transaction-id required, COMMIT")
EREQTIDABT = Error("transaction-id required, ABORT")
// Subscription errors.
EDUPSID = Error("duplicate subscription-id")
EBADSID = Error("invalid subscription-id")
// Unscubscribe error.
EUNOSID = Error("id required, UNSUBSCRIBE")
// Unsupported version error.
EBADVERCLI = Error("unsupported protocol version, client")
EBADVERSVR = Error("unsupported protocol version, server")
EBADVERNAK = Error("unsupported protocol version, NACK")
// Unsupported Headers type.
EBADHDR = Error("unsupported Headers type")
// Receipt not allowed on connect
ENORECPT = Error("receipt not allowed on CONNECT")
A zero length buffer for convenience.
var NULLBUFF = make([]uint8, 0)
Codec data structure definition.
type codecdata struct {
encoded string
decoded string
STOMP specification defined encoded / decoded values for the Message
command and headers.
var codec_values = []codecdata{
codecdata{"\\\\", "\\"},
codecdata{"\\" + "n", "\n"},
codecdata{"\\c", ":"},
Control data for initialization of heartbeats with STOMP 1.1+, and the
subsequent control of any heartbeat routines.
type heartbeat_data struct {
cx int64 // client send value, ms
cy int64 // client receive value, ms
sx int64 // server send value, ms
sy int64 // server receive value, ms
hbs bool // sending heartbeats
hbr bool // receiving heartbeats
sti int64 // local sender ticker interval, ns
rti int64 // local receiver ticker interval, ns
sc int64 // local sender ticker count
rc int64 // local receiver ticker count
ssd chan bool // sender shutdown channel
rsd chan bool // receiver shutdown channel
ls int64 // last send time, ns
lr int64 // last receive time, ns
Jump to Line
Something went wrong with that request. Please try again.