MCPcopy
hub / github.com/davyxu/cellnet / sendLoop

Method sendLoop

peer/tcp/session.go:180–217  ·  view source on GitHub ↗

发送循环

()

Source from the content-addressed store, hash-verified

178
179// 发送循环
180func (self *tcpSession) sendLoop() {
181
182 var writeList []interface{}
183
184 var capturePanic bool
185
186 if i, ok := self.Peer().(cellnet.PeerCaptureIOPanic); ok {
187 capturePanic = i.CaptureIOPanic()
188 }
189
190 for {
191 writeList = writeList[0:0]
192 exit := self.sendQueue.Pick(&writeList)
193
194 // 遍历要发送的数据
195 for _, msg := range writeList {
196
197 if capturePanic {
198 self.protectedSendMessage(&cellnet.SendMsgEvent{Ses: self, Msg: msg})
199 } else {
200 self.SendMessage(&cellnet.SendMsgEvent{Ses: self, Msg: msg})
201 }
202 }
203
204 if exit {
205 break
206 }
207 }
208
209 // 完整关闭
210 conn := self.Conn()
211 if conn != nil {
212 conn.Close()
213 }
214
215 // 通知完成
216 self.exitSync.Done()
217}
218
219// 启动会话的各种资源
220func (self *tcpSession) Start() {

Callers 1

StartMethod · 0.95

Calls 8

PeerMethod · 0.95
protectedSendMessageMethod · 0.95
ConnMethod · 0.95
PickMethod · 0.80
SendMessageMethod · 0.80
DoneMethod · 0.80
CaptureIOPanicMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected