Add user.stop
This commit is contained in:
parent
b71fcc2e00
commit
ef01142a44
14
user.go
14
user.go
@ -45,6 +45,8 @@ type eventDownstreamDisconnected struct {
|
|||||||
dc *downstreamConn
|
dc *downstreamConn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type eventStop struct{}
|
||||||
|
|
||||||
type networkHistory struct {
|
type networkHistory struct {
|
||||||
offlineClients map[string]uint64 // indexed by client name
|
offlineClients map[string]uint64 // indexed by client name
|
||||||
ring *Ring // can be nil if there are no offline clients
|
ring *Ring // can be nil if there are no offline clients
|
||||||
@ -416,6 +418,14 @@ func (u *user) run() {
|
|||||||
dc.logger.Printf("failed to handle message %q: %v", msg, err)
|
dc.logger.Printf("failed to handle message %q: %v", msg, err)
|
||||||
dc.Close()
|
dc.Close()
|
||||||
}
|
}
|
||||||
|
case eventStop:
|
||||||
|
u.forEachDownstream(func(dc *downstreamConn) {
|
||||||
|
dc.Close()
|
||||||
|
})
|
||||||
|
for _, n := range u.networks {
|
||||||
|
n.stop()
|
||||||
|
}
|
||||||
|
return
|
||||||
default:
|
default:
|
||||||
u.srv.Logger.Printf("received unknown event type: %T", e)
|
u.srv.Logger.Printf("received unknown event type: %T", e)
|
||||||
}
|
}
|
||||||
@ -550,3 +560,7 @@ func (u *user) updatePassword(hashed string) error {
|
|||||||
u.User.Password = hashed
|
u.User.Password = hashed
|
||||||
return u.srv.db.StoreUser(&u.User)
|
return u.srv.db.StoreUser(&u.User)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *user) stop() {
|
||||||
|
u.events <- eventStop{}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user