欢迎光临散文网 会员登陆 & 注册

宽哥云原生Go语言入门到脚手架项目实战

2023-08-22 14:41 作者:bili_57619593086  | 我要投稿

// Client is a middleman between the websocket connection and the hub.type Client struct {    hub *Hub    // The websocket connection.    conn *websocket.Conn    // Buffered channel of outbound messages.    send chan []byte}// readPump pumps messages from the websocket connection to the hub.//// The application runs readPump in a per-connection goroutine. The application// ensures that there is at most one reader on a connection by executing all// reads from this goroutine.func (c *Client) readPump() {    defer func() {        c.hub.unregister <- c        c.conn.Close()    }()    c.conn.SetReadLimit(maxMessageSize)    c.conn.SetReadDeadline(time.Now().Add(pongWait))    c.conn.SetPongHandler(func(string) error { c.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })    for {        _, message, err := c.conn.ReadMessage()        if err != nil {

宽哥云原生Go语言入门到脚手架项目实战的评论 (共 条)

分享到微博请遵守国家法律