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

Method StartWriter

znet/ws_connection.go:185–206  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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

Callers 2

SendToQueueMethod · 0.95
SendBuffMsgMethod · 0.95

Calls 6

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

Tested by

no test coverage detected