33 lines
544 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
last := time.Now()
go func() {
for {
if time.Now().After(last.Add(time.Second)) {
fmt.Printf("%d packets per second, %d clients\n", server.PacketCount(), game.Clients.Count())
last = time.Now()
server.ResetPacketCount()
}
}
}()
// Start listening
server.Run(4242)
}