mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
refactor(channelserver): replace init() handler registration with explicit construction
The handler table was a package-level global populated by init(), making registration implicit and untestable. Move it to buildHandlerTable() which returns the map, store it as a Server struct field initialized in NewServer(), and add a missing-handler guard in handlePacketGroup to log a warning instead of panicking on unknown opcodes.
This commit is contained in:
@@ -38,10 +38,11 @@ func (m *mockPacket) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext
|
||||
func createMockServer() *Server {
|
||||
logger, _ := zap.NewDevelopment()
|
||||
s := &Server{
|
||||
logger: logger,
|
||||
erupeConfig: &_config.Config{},
|
||||
stages: make(map[string]*Stage),
|
||||
sessions: make(map[net.Conn]*Session),
|
||||
logger: logger,
|
||||
erupeConfig: &_config.Config{},
|
||||
stages: make(map[string]*Stage),
|
||||
sessions: make(map[net.Conn]*Session),
|
||||
handlerTable: buildHandlerTable(),
|
||||
raviente: &Raviente{
|
||||
register: make([]uint32, 30),
|
||||
state: make([]uint32, 30),
|
||||
|
||||
Reference in New Issue
Block a user