move router to module New func

This commit is contained in:
Joel Wetzell
2025-12-06 23:00:45 -06:00
parent 8d8347fc4d
commit 9a06949b5b
16 changed files with 30 additions and 93 deletions

View File

@@ -28,7 +28,7 @@ type TCPServer struct {
func init() {
RegisterModule(ModuleRegistration{
Type: "net.tcp.server",
New: func(config config.ModuleConfig) (Module, error) {
New: func(config config.ModuleConfig, router *Router) (Module, error) {
params := config.Params
port, ok := params["port"]
if !ok {
@@ -76,7 +76,7 @@ func init() {
return nil, err
}
return &TCPServer{Framer: framer, Addr: addr, config: config, quit: make(chan interface{})}, nil
return &TCPServer{Framer: framer, Addr: addr, config: config, quit: make(chan interface{}), router: router}, nil
},
})
}
@@ -89,10 +89,6 @@ func (ts *TCPServer) Type() string {
return ts.config.Type
}
func (ts *TCPServer) RegisterRouter(router *Router) {
ts.router = router
}
func (ts *TCPServer) handleClient(client *net.TCPConn) {
ts.connectionsMu.Lock()
ts.connections = append(ts.connections, client)