X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/0fcfa5d54b166559c0ca31932a71a7eabb79c72c..19dcc94821d1fac803c571b1dc11764213713682:/hotline/client_conn.go diff --git a/hotline/client_conn.go b/hotline/client_conn.go index a3c5258..997b9c9 100644 --- a/hotline/client_conn.go +++ b/hotline/client_conn.go @@ -172,7 +172,9 @@ func (cc *ClientConn) Disconnect() { delete(cc.Server.Clients, binary.BigEndian.Uint16(*cc.ID)) - cc.notifyOthers(*NewTransaction(tranNotifyDeleteUser, nil, NewField(fieldUserID, *cc.ID))) + for _, t := range cc.notifyOthers(*NewTransaction(tranNotifyDeleteUser, nil, NewField(fieldUserID, *cc.ID))) { + cc.Server.outbox <- t + } if err := cc.Connection.Close(); err != nil { cc.Server.Logger.Errorw("error closing client connection", "RemoteAddr", cc.RemoteAddr) @@ -180,13 +182,14 @@ func (cc *ClientConn) Disconnect() { } // notifyOthers sends transaction t to other clients connected to the server -func (cc *ClientConn) notifyOthers(t Transaction) { +func (cc *ClientConn) notifyOthers(t Transaction) (trans []Transaction) { for _, c := range sortedClients(cc.Server.Clients) { if c.ID != cc.ID && c.Agreed { t.clientID = c.ID - cc.Server.outbox <- t + trans = append(trans, t) } } + return trans } // NewReply returns a reply Transaction with fields for the ClientConn