ComunicRTCProxy/ws.go

42 lines
622 B
Go

// Websocket controller
//
// @author Pierre HUBERT
package main
import (
"log"
"github.com/gorilla/websocket"
)
// Open websocket connection
func openWs(conf *Config) {
u := conf.getURL()
log.Printf("Connecting to %s", u.String())
// Connect to Websocket
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
if err != nil {
log.Fatal("dial:", err)
}
defer c.Close()
// Read remote messages
for {
_, message, err := c.ReadMessage()
if err != nil {
log.Printf("WS Read error: %s", err.Error())
return
}
// TODO : process incoming messages
log.Printf("recv: %s", message)
}
}