Files
bl/common/socket/kick.go

51 lines
882 B
Go
Raw Normal View History

package socket
import (
"blazing/cool"
"blazing/logic/service/player"
"context"
"fmt"
)
type Broadcast struct {
Name string
}
func (s *Server) Broadcast(t string) int {
cool.Logger.Info(context.TODO(), "全服广播", t)
var count int
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
count++
value.SendPackCmd(50003, &Broadcast{
Name: t,
})
return true
})
return count
}
func (s *Server) KickPerson(a int) error {
cool.Logger.Info(context.TODO(), "检测到踢人请求", a)
if a == 0 {
return nil
}
return player.KickPlayer(uint32(a))
}
// 参数不为0是强制踢出
func (s *Server) QuitSelf(a int) error {
//TODO 这里待退出
fmt.Println("检测到退出请求")
s.quit = true
if a != 0 {
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
value.Kick()
return true
})
}
return nil
}