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

Method Start

znet/kcp_connection.go:277–310  ·  view source on GitHub ↗

Start starts the connection and makes the current connection work. (启动连接,让当前连接开始工作)

()

Source from the content-addressed store, hash-verified

275// Start starts the connection and makes the current connection work.
276// (启动连接,让当前连接开始工作)
277func (c *KcpConnection) Start() {
278 defer func() {
279 if err := recover(); err != nil {
280 zlog.Ins().ErrorF("Connection Start() error: %v", err)
281 }
282 }()
283 c.ctx, c.cancel = context.WithCancel(context.Background())
284
285 // Execute the hook method for processing business logic when creating a connection
286 // (按照用户传递进来的创建连接时需要处理的业务,执行钩子方法)
287 c.callOnConnStart()
288
289 // Start heartbeating detection
290 if c.hc != nil {
291 c.hc.Start()
292 c.updateActivity()
293 }
294
295 // 占用workerid
296 c.workerID = useWorker(c)
297
298 // Start the Goroutine for reading data from the client
299 // (开启用户从客户端读取数据流程的Goroutine)
300 go c.StartReader()
301
302 select {
303 case <-c.ctx.Done():
304 c.finalizer()
305
306 // 归还workerid
307 freeWorker(c)
308 return
309 }
310}
311
312// Stop stops the connection and ends the current connection state.
313// (停止连接,结束当前连接状态)

Callers

nothing calls this directly

Calls 9

callOnConnStartMethod · 0.95
updateActivityMethod · 0.95
StartReaderMethod · 0.95
finalizerMethod · 0.95
InsFunction · 0.92
useWorkerFunction · 0.85
freeWorkerFunction · 0.85
ErrorFMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected