Preparations for service infrastructure

This commit is contained in:
Andreas Neue 2016-08-21 23:57:53 +02:00
parent ae81e484d3
commit 258cb6e4f9
1 changed files with 14 additions and 0 deletions

View File

@ -47,6 +47,8 @@ type Server struct {
clients map[string]Client clients map[string]Client
clModes map[string]string clModes map[string]string
services map[string]*Service
chUsers map[string]map[string]string chUsers map[string]map[string]string
chTopics map[string]string chTopics map[string]string
chModes map[string]map[string]bool chModes map[string]map[string]bool
@ -75,6 +77,8 @@ func NewServer(configPath, software, version string) *Server {
sv.clients = make(map[string]Client) sv.clients = make(map[string]Client)
sv.clModes = make(map[string]string) sv.clModes = make(map[string]string)
sv.services = make(map[string]*Service, 0)
sv.chUsers = make(map[string]map[string]string) sv.chUsers = make(map[string]map[string]string)
sv.chTopics = make(map[string]string) sv.chTopics = make(map[string]string)
sv.chModes = make(map[string]map[string]bool) sv.chModes = make(map[string]map[string]bool)
@ -151,6 +155,16 @@ func (sv *Server) DelClient(cl Client) {
sv.delq <- cl 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) { func (sv *Server) listen(laddr string) {
listen, err := net.Listen("tcp", laddr) listen, err := net.Listen("tcp", laddr)
if err != nil { if err != nil {