mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 13:25:40 +00:00
move router to module New func
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user