websocket fixed

This commit is contained in:
alessio 2016-12-18 23:02:48 +01:00
parent 51238900af
commit e69e687407
2 changed files with 12 additions and 9 deletions

View File

@ -103,16 +103,19 @@ func (s *Server) projects(c echo.Context) error {
defer ws.Close()
msg, _ := json.Marshal(s.Blueprint.Projects)
err := websocket.Message.Send(ws, string(msg))
for {
select {
case <-s.Sync:
msg, _ := json.Marshal(s.Blueprint.Projects)
err = websocket.Message.Send(ws, string(msg))
if err != nil {
break
go func() {
for {
select {
case <-s.Sync:
msg, _ := json.Marshal(s.Blueprint.Projects)
err = websocket.Message.Send(ws, string(msg))
if err != nil {
break
}
}
}
}()
for {
// Read
text := ""
err := websocket.Message.Receive(ws, &text)

View File

@ -22,7 +22,7 @@ func init() {
// Open a url in the default browser
func Open(url string) (io.Writer, error) {
open, err := cmd[runtime.GOOS];
open, err := cmd[runtime.GOOS]
if !err {
return nil, errors.New("This operating system is not supported.")
}