mirror of
https://gitlab.com/comunic/ComunicRTCProxy
synced 2024-11-17 02:51:12 +00:00
42 lines
622 B
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)
|
|
|
|
}
|
|
|
|
}
|