Skip to content

Commit

Permalink
broadcast if msg add success
Browse files Browse the repository at this point in the history
  • Loading branch information
TATAUFO committed Feb 1, 2020
1 parent 55a8809 commit 55cdf15
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,17 @@ func (n Node) wsHandler(ws *websocket.Conn) {
break
}
if err = json.Unmarshal([]byte(content), &msg); err != nil {
log.Error("decode message fail", err)
log.Error("Decode message fail", err)
}
log.Info("Msg received", common.Hash2String(msg.ID()))

if err = websocket.Message.Send(ws, resByte); err != nil {
log.Error("Send fail", err)
}
// save msg (universe & udb)
if err = n.saveMsg(&msg); err != nil {
log.Error("Add new msg fail", err)
}

if err = websocket.Message.Send(ws, resByte); err != nil {
log.Error("send fail", err)
} else if err = n.broadcastMsg(&msg); err != nil {
log.Error("Broadcast", common.Hash2String(msg.ID()))
}
}
}
Expand Down

0 comments on commit 55cdf15

Please sign in to comment.