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