kick players when keepalive timeout

This commit is contained in:
Tnze
2021-12-24 20:40:24 +08:00
parent 494a52320d
commit 1742fde1ff
4 changed files with 7 additions and 17 deletions

View File

@ -28,6 +28,7 @@ func main() {
time.Sleep(time.Second * 3)
}
}(i)
time.Sleep(time.Millisecond)
}
select {}
}
@ -46,7 +47,6 @@ func newIndividual(id int, name string) (i *individual) {
i.player = basic.NewPlayer(i.client, basic.DefaultSettings)
basic.EventsListener{
GameStart: i.onGameStart,
Death: i.onDeath,
Disconnect: onDisconnect,
}.Attach(i.client)
return
@ -68,19 +68,6 @@ func (i *individual) run(address string) {
log.Printf("[%d] Handle game error: %v", i.id, err)
}
func (i *individual) onDeath() error {
log.Printf("[%d]Died and Respawned", i.id)
// If we exclude Respawn(...) then the player won't press the "Respawn" button upon death
go func() {
time.Sleep(time.Second * 5)
err := i.player.Respawn()
if err != nil {
log.Print(err)
}
}()
return nil
}
func (i *individual) onGameStart() error {
log.Printf("[%d]Game start", i.id)
return nil