Add SendJSON() to uibroadcaster.

pull/516/head
Christopher Young 2016-10-24 15:36:54 -04:00
rodzic 27206c0751
commit 504d97ec7a
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -11,6 +11,7 @@
package main
import (
"encoding/json"
"golang.org/x/net/websocket"
"sync"
"time"
@ -36,6 +37,11 @@ func (u *uibroadcaster) Send(msg []byte) {
u.messages <- msg
}
func (u *uibroadcaster) SendJSON(i interface{}) {
j, _ := json.Marshal(&i)
u.Send(j)
}
func (u *uibroadcaster) AddSocket(sock *websocket.Conn) {
u.sockets_mu.Lock()
u.sockets = append(u.sockets, sock)