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

Method sendLoop

peer/gorillaws/session.go:83–111  ·  view source on GitHub ↗

发送循环

()

Source from the content-addressed store, hash-verified

81
82// 发送循环
83func (self *wsSession) sendLoop() {
84
85 var writeList []interface{}
86
87 for {
88 writeList = writeList[0:0]
89 exit := self.sendQueue.Pick(&writeList)
90
91 // 遍历要发送的数据
92 for _, msg := range writeList {
93
94 // TODO SendMsgEvent并不是很有意义
95 self.SendMessage(&cellnet.SendMsgEvent{Ses: self, Msg: msg})
96 }
97
98 if exit {
99 break
100 }
101 }
102
103 // 关闭连接
104 if self.conn != nil {
105 self.conn.Close()
106 self.conn = nil
107 }
108
109 // 通知完成
110 self.exitSync.Done()
111}
112
113// 启动会话的各种资源
114func (self *wsSession) Start() {

Callers 1

StartMethod · 0.95

Calls 4

PickMethod · 0.80
SendMessageMethod · 0.80
DoneMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected