Skip to content

Commit

Permalink
Fix iOS 15 since it doesn't support compressed fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedmansour committed Oct 27, 2021
1 parent b66d375 commit d282823
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions daemon/hub/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const (
maxMessageSize = 512
)

var (
newline = []byte{'\n'}
)

// Client is a middleman between the websocket connection and the hub.
type Client struct {
mu sync.Mutex
Expand Down Expand Up @@ -181,20 +177,15 @@ func (c *Client) writePump() {
return
}

w, err := c.conn.NextWriter(websocket.TextMessage)
if err != nil {
return
}
w.Write(message)

// Add queued chat messages to the current websocket message.
m := message[0:len(message):len(message)] // force new allocation on append
n := len(c.send)
for i := 0; i < n; i++ {
w.Write(newline)
w.Write(<-c.send)
m = append(m, '\n')
m = append(m, <-c.send...)
}

if err := w.Close(); err != nil {

err := c.conn.WriteMessage(websocket.TextMessage, m)
if err != nil {
return
}

Expand Down

0 comments on commit d282823

Please sign in to comment.