diff --git a/server.go b/server.go index f3086e2..b07ce04 100644 --- a/server.go +++ b/server.go @@ -47,6 +47,8 @@ type Server struct { clients map[string]Client clModes map[string]string + services map[string]*Service + chUsers map[string]map[string]string chTopics map[string]string chModes map[string]map[string]bool @@ -75,6 +77,8 @@ func NewServer(configPath, software, version string) *Server { sv.clients = make(map[string]Client) sv.clModes = make(map[string]string) + sv.services = make(map[string]*Service, 0) + sv.chUsers = make(map[string]map[string]string) sv.chTopics = make(map[string]string) sv.chModes = make(map[string]map[string]bool) @@ -151,6 +155,16 @@ func (sv *Server) DelClient(cl Client) { sv.delq <- cl } +func (sv *Server) LinkService(name string, svc *Service) { + sv.services[name] = svc + svc.Run() +} + +func (sv *Server) UnlinkService(name string) { + sv.services[name].Stop() + delete(sv.services, name) +} + func (sv *Server) listen(laddr string) { listen, err := net.Listen("tcp", laddr) if err != nil {