mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-06 22:59:44 +00:00
wip
This commit is contained in:
parent
a9a6a9e275
commit
672574ed01
@ -1031,13 +1031,23 @@ func ConnectWebSocket(c *gin.Context) {
|
|||||||
fmt.Println("有溢出", list)
|
fmt.Println("有溢出", list)
|
||||||
}
|
}
|
||||||
if len(list) > 10 {
|
if len(list) > 10 {
|
||||||
|
kickoutList := []Client{}
|
||||||
count := len(list) - 10
|
count := len(list) - 10
|
||||||
for i := len(list) - 1; count > 0 && i > -1; i-- {
|
for i := len(list) - 1; count > 0 && i > -1; i-- {
|
||||||
if _, ok := handler.clients[list[i].ID]; !ok {
|
if _, ok := handler.clients[list[i].ID]; !ok {
|
||||||
count--
|
count--
|
||||||
|
kickoutList = append(kickoutList, Client{ID: list[i].ID, Name: service.GetNameByDB(list[i]), IP: list[i].IP, Offline: true})
|
||||||
service.MyService.Peer().DeletePeer(list[i].ID)
|
service.MyService.Peer().DeletePeer(list[i].ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(kickoutList) > 0 {
|
||||||
|
other := make(map[string]interface{})
|
||||||
|
other["type"] = "kickout"
|
||||||
|
other["peers"] = kickoutList
|
||||||
|
otherBy, err := json.Marshal(other)
|
||||||
|
fmt.Println(err)
|
||||||
|
client.handler.broadcast <- otherBy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
list = service.MyService.Peer().GetPeers()
|
list = service.MyService.Peer().GetPeers()
|
||||||
if len(list) > 10 {
|
if len(list) > 10 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user