2 // Copyright © 2013-2016 Guy M. Allard
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 Connect and Disconnect from a STOMP broker using TCP.
22 # Connect to a broker with all defaults:
27 # Virtual Host is "localhost"
31 # Connect to a broker using STOMP protocol level 1.0:
32 STOMP_PROTOCOL=1.0 go run conndisc.go
34 # Connect to a broker using a custom host and port:
35 STOMP_HOST=tjjackson STOMP_PORT=62613 go run conndisc.go
37 # Connect to a broker using a custom port and virtual host:
38 STOMP_PORT=41613 STOMP_VHOST="/" go run conndisc.go
40 # Connect to a broker using a custom login and passcode:
41 STOMP_LOGIN="userid" STOMP_PASSCODE="t0ps3cr3t" go run conndisc.go
50 // sngecomm methods are used specifically for these example clients.
51 "github.com/gmallard/stompngo_examples/sngecomm"
55 exampid
= "conndisc: "
56 ll
= log
.New(os
.Stdout
, "ECNDS ", log
.Ldate|log
.Lmicroseconds|log
.Lshortfile
)
60 // Connect to a STOMP broker and disconnect.
65 // Standard example connect sequence
66 n
, conn
, e
:= sngecomm
.CommonConnect(exampid
, tag
, ll
)
68 ll
.Fatalf("%stag:%s connsess:%s main_on_connect error:%v",
69 exampid
, tag
, sngecomm
.Lcs
,
70 e
.Error()) // Handle this ......
73 // *NOTE* application specific functionaltiy starts here!
75 // *NOTE* application specific functionaltiy ends here!
77 // Standard example disconnect sequence
78 e
= sngecomm
.CommonDisconnect(n
, conn
, exampid
, tag
, ll
)
80 ll
.Fatalf("%stag:%s connsess:%s main_on_disconnect error:%v",
81 exampid
, tag
, conn
.Session(),
82 e
.Error()) // Handle this ......
85 ll
.Printf("%stag:%s connsess:%s main_elapsed:%v\n",
86 exampid
, tag
, conn
.Session(),