package server import ( "io" "git.loafle.net/commons_go/rpc" "git.loafle.net/commons_go/server/ipc" ) func NewServerHandler(addr string, registry rpc.Registry) *ServerHandlers { sh := &ServerHandlers{ registry: registry, } sh.Addr = addr return sh } type ServerHandlers struct { ipc.ServerHandlers registry rpc.Registry workersChan chan struct{} } func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) { contentType := "json" Loop: for { if err := sh.registry.Invoke(contentType, rwc, rwc, nil, nil); nil != err && sh.IsClientDisconnect(err) { stopChan <- struct{}{} break Loop } select { case <-stopChan: return default: } } }