|
|
@@ -13,13 +13,18 @@ var stompConnection *stomp.Conn
|
|
|
|
|
|
func getStompConnection() *stomp.Conn {
|
|
|
if stompConnection == nil {
|
|
|
- stompConnection, _ = stomp.Dial("tcp", *flag.StompUrl)
|
|
|
+ var err error
|
|
|
+ stompConnection, err = stomp.Dial("tcp", *flag.StompUrl)
|
|
|
+ if(err != nil) {
|
|
|
+ log.Printf("Error creating stomp connection error: %v\n", err)
|
|
|
+ } else {
|
|
|
+ log.Println("Created stomp connection")
|
|
|
+ }
|
|
|
}
|
|
|
return stompConnection
|
|
|
}
|
|
|
|
|
|
func SendJson(topic string, v interface{}) {
|
|
|
b, _ := json.Marshal(v)
|
|
|
- log.Printf("Sending stomp to topic %v\n", topic)
|
|
|
getStompConnection().Send("/topic/go-battlecamp."+topic, "application/json;charset=utf-8", b, stomp.SendOpt.NoContentLength)
|
|
|
}
|