MCPcopy
hub / github.com/aceld/zinx / Start

Method Start

znet/server.go:431–457  ·  view source on GitHub ↗

Start the network service (开启网络服务)

()

Source from the content-addressed store, hash-verified

429// Start the network service
430// (开启网络服务)
431func (s *Server) Start() {
432 s.exitChan = make(chan struct{})
433
434 // Add decoder to interceptors head
435 // (将解码器添加到拦截器最前面)
436 if s.decoder != nil {
437 s.msgHandler.SetHeadInterceptor(s.decoder)
438 }
439 // Start worker pool mechanism
440 // (启动worker工作池机制)
441 s.msgHandler.StartWorkerPool()
442
443 // Start a goroutine to handle server listener business
444 // (开启一个go去做服务端Listener业务)
445 switch zconf.GlobalObject.Mode {
446 case zconf.ServerModeTcp:
447 go s.ListenTcpConn()
448 case zconf.ServerModeWebsocket:
449 go s.ListenWebsocketConn()
450 case zconf.ServerModeKcp:
451 go s.ListenKcpConn()
452 default:
453 go s.ListenTcpConn()
454 go s.ListenWebsocketConn()
455 }
456
457}
458
459// Stop stops the server (停止服务)
460func (s *Server) Stop() {

Callers 3

ServeMethod · 0.95
TestServerDeadLockFunction · 0.95

Calls 5

ListenTcpConnMethod · 0.95
ListenWebsocketConnMethod · 0.95
ListenKcpConnMethod · 0.95
SetHeadInterceptorMethod · 0.65
StartWorkerPoolMethod · 0.65

Tested by 2

TestServerDeadLockFunction · 0.76