Internal change.
PiperOrigin-RevId: 233124342 Change-Id: Id4b4857af89815ffb9254cc30df4244b2768d9f2
This commit is contained in:
parent
9c9386d2a8
commit
b2aa213dd2
|
@ -175,13 +175,23 @@ type Server struct {
|
||||||
|
|
||||||
// wg is a wait group for all outstanding clients.
|
// wg is a wait group for all outstanding clients.
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
// afterRPCCallback is called after each RPC is successfully completed.
|
||||||
|
afterRPCCallback func()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer returns a new server.
|
// NewServer returns a new server.
|
||||||
func NewServer() *Server {
|
func NewServer() *Server {
|
||||||
|
return NewServerWithCallback(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewServerWithCallback returns a new server, who upon completion of each RPC
|
||||||
|
// calls the given function.
|
||||||
|
func NewServerWithCallback(afterRPCCallback func()) *Server {
|
||||||
return &Server{
|
return &Server{
|
||||||
methods: make(map[string]registeredMethod),
|
methods: make(map[string]registeredMethod),
|
||||||
clients: make(map[*unet.Socket]clientState),
|
clients: make(map[*unet.Socket]clientState),
|
||||||
|
afterRPCCallback: afterRPCCallback,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +284,11 @@ func (s *Server) handleOne(client *unet.Socket) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if s.afterRPCCallback != nil {
|
||||||
|
s.afterRPCCallback()
|
||||||
|
}
|
||||||
|
}()
|
||||||
// Explicitly close all these files after the call.
|
// Explicitly close all these files after the call.
|
||||||
//
|
//
|
||||||
// This is also explicitly a reference to the files after the call,
|
// This is also explicitly a reference to the files after the call,
|
||||||
|
|
Loading…
Reference in New Issue