Commit 3a2efbcc authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Send chathistory messages in the client goroutine.

We used to send the chat history from the reader goroutine,
which would cause them to race with the join message.
parent 533e4b9b
......@@ -1177,7 +1177,7 @@ func handleAction(c *webClient, a interface{}) error {
}
}
perms := append([]string(nil), c.permissions...)
return c.write(clientMessage{
err := c.write(clientMessage{
Type: "joined",
Kind: a.kind,
Group: a.group,
......@@ -1187,6 +1187,23 @@ func handleAction(c *webClient, a interface{}) error {
Data: data,
RTCConfiguration: ice.ICEConfiguration(),
})
if err != nil {
return err
}
h := c.group.GetChatHistory()
for _, m := range h {
err := c.write(clientMessage{
Type: "chathistory",
Id: m.Id,
Username: m.User,
Time: m.Time,
Value: m.Value,
Kind: m.Kind,
})
if err != nil {
return err
}
}
case permissionsChangedAction:
g := c.Group()
if g == nil {
......@@ -1426,20 +1443,6 @@ func handleClientMessage(c *webClient, m clientMessage) error {
})
}
c.group = g
h := c.group.GetChatHistory()
for _, m := range h {
err := c.write(clientMessage{
Type: "chathistory",
Id: m.Id,
Username: m.User,
Time: m.Time,
Value: m.Value,
Kind: m.Kind,
})
if err != nil {
return err
}
}
case "request":
requested, err := parseRequested(m.Request)
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment