我无法理解这部分使用c.conn.SetWriteDeadline函数的代码。
// Time allowed to write a message to the peer.
writeWait = 10 * time.Second
// Time allowed to read the next pong message from the peer.
pongWait = 60 * time.Second
// Send pings to peer with this period. Must be less than pongWait.
pingPeriod = (pongWait * 9) / 10
// A goroutine running writePump is started for each connection. The
// application ensures that there is at most one writer to a connection by
// executing all writes from this goroutine.
func (c *Client) writePump() {
ticker := time.NewTicker(pingPeriod)
defer func() {
ticker.Stop()
c.conn.Close()
}()
for {
select {
case message, ok := <-c.send:
// LOGIC TO WRITE MESSAGE TO THE CONNECTION
case <-ticker.C:
c.conn.SetWriteDeadline(time.Now().Add(writeWait)) // 👈 ??
if err := c.conn.WriteMessage(websocket.PingMessage, nil); err != nil {
return
}
}
}
}
我无法理解票务渠道逻辑。我们想在这里实现什么?
我指的是go/gorilla/websocket
这里的官方码头
慕雪6442864
相关分类