]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/client_conn.go
Fix intermittently failing banner download
[rbdr/mobius] / hotline / client_conn.go
index a3c5258c48b9963ea292c1c9fd10a719ad3c2f31..997b9c921a50966cd368f27b3cf48739cc41c16a 100644 (file)
@@ -172,7 +172,9 @@ func (cc *ClientConn) Disconnect() {
 
        delete(cc.Server.Clients, binary.BigEndian.Uint16(*cc.ID))
 
 
        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)
 
        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
 }
 
 // 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
        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
 }
 
 // NewReply returns a reply Transaction with fields for the ClientConn