From e69e6874074de0ba180d1df018e78a0ed1784c1c Mon Sep 17 00:00:00 2001 From: alessio Date: Sun, 18 Dec 2016 23:02:48 +0100 Subject: [PATCH] websocket fixed --- server/main.go | 19 +++++++++++-------- server/open.go | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/server/main.go b/server/main.go index 55867b1..76e1280 100644 --- a/server/main.go +++ b/server/main.go @@ -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) diff --git a/server/open.go b/server/open.go index 598b1e0..22ba233 100644 --- a/server/open.go +++ b/server/open.go @@ -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.") }