33 lines
525 B
Go
Raw Normal View History

2024-01-24 19:57:31 +00:00
package main
import (
"fmt"
"server/core"
"server/game"
"server/packet"
"time"
)
func main() {
// Init server
server := core.New()
server.SetHandler(packet.Ping, game.Ping)
server.SetHandler(packet.Login, game.Login)
// Show statistics
2024-01-24 21:40:05 +00:00
ticker := time.NewTicker(time.Second)
2024-01-24 19:57:31 +00:00
go func() {
for {
2024-01-24 21:40:05 +00:00
select {
case <-ticker.C:
2024-01-24 19:57:31 +00:00
fmt.Printf("%d packets per second, %d clients\n", server.PacketCount(), game.Clients.Count())
server.ResetPacketCount()
}
}
}()
// Start listening
server.Run(4242)
}