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

Method StartWriter

znet/kcp_connection.go:189–210  ·  view source on GitHub ↗

StartWriter is the goroutine that writes messages to the client (写消息Goroutine, 用户将数据发送给客户端)

()

Source from the content-addressed store, hash-verified

187// StartWriter is the goroutine that writes messages to the client
188// (写消息Goroutine, 用户将数据发送给客户端)
189func (c *KcpConnection) StartWriter() {
190 zlog.Ins().DebugF("Writer Goroutine is running")
191 defer zlog.Ins().DebugF("%s [conn Writer exit!]", c.RemoteAddr().String())
192
193 for {
194 select {
195 case data, ok := <-c.msgBuffChan:
196 if ok {
197 if err := c.Send(data); err != nil {
198 zlog.Ins().ErrorF("Send Buff Data error:, %s Conn Writer exit", err)
199 break
200 }
201
202 } else {
203 zlog.Ins().ErrorF("msgBuffChan is Closed")
204 break
205 }
206 case <-c.ctx.Done():
207 return
208 }
209 }
210}
211
212// StartReader is a goroutine that reads data from the client
213// (读消息Goroutine,用于从客户端中读取数据)

Callers 2

SendToQueueMethod · 0.95
SendBuffMsgMethod · 0.95

Calls 6

RemoteAddrMethod · 0.95
SendMethod · 0.95
InsFunction · 0.92
DebugFMethod · 0.65
ErrorFMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected