30 lines
501 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() {
2024-01-24 22:06:45 +00:00
for range ticker.C {
fmt.Printf("%d packets per second, %d clients\n", server.PacketCount(), game.Clients.Count())
server.ResetPacketCount()
2024-01-24 19:57:31 +00:00
}
}()
// Start listening
server.Run(4242)
}