// 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.
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.
// 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 (sess *PageSession) readPump() {
	defer func() {
		sess.connected = false
		sess.Page.connected = false
		if err := sess.weConn.Close(); err != nil {
			sess.logger.Err(err).Msg("ws conn close")
		} else {
			sess.logger.Trace().Msg("ws close")
		}
	}()
	if err := sess.weConn.SetReadDeadline(time.Now().Add(pongWait)); err != nil {
		sess.logger.Err(err).Msg("read pump set read deadline")
	}
	sess.weConn.SetPongHandler(func(string) error {
		sess.logger.Trace().Msg("ws pong")
		if err := sess.weConn.SetReadDeadline(time.Now().Add(pongWait)); err != nil {
			sess.logger.Err(err).Msg("pong handler: set read deadline")
		}
		return nil
	})
	for {
		mt, message, err := sess.weConn.ReadMessage()
		if err != nil {
			if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
				sess.logger.Debug().Err(err).Msg("unexpected close error")
			}
			break
		}
		sess.LastActive = time.Now()
		sess.Receive <- MessageWS{
			Message:  message,
			IsBinary: mt == websocket.BinaryMessage,
		}
	}
}
func ( sess * PageSession ) readPump ( ) { defer func ( ) { sess . connected = false sess . Page . connected = false if err := sess . weConn . Close ( ) ; err != nil { sess . logger . Err ( err ) . Msg ( " " ) } else { sess . logger . Trace ( ) . Msg ( " " ) } } ( ) if err := sess . weConn . SetReadDeadline ( time . Now ( ) . Add ( pongWait ) ) ; err != nil { sess . logger . Err ( err ) . Msg ( " " ) } sess . weConn . SetPongHandler ( func ( string ) error { sess . logger . Trace ( ) . Msg ( " " ) if err := sess . weConn . SetReadDeadline ( time . Now ( ) . Add ( pongWait ) ) ; err != nil { sess . logger . Err ( err ) . Msg ( " " ) } return nil } ) for { mt , message , err := sess . weConn . ReadMessage ( ) if err != nil { if websocket . IsUnexpectedCloseError ( err , websocket . CloseGoingAway , websocket . CloseAbnormalClosure ) { sess . logger . Debug ( ) . Err ( err ) . Msg ( " " ) } break } sess . LastActive = time . Now ( ) sess . Receive <- MessageWS { Message : message , IsBinary : mt == websocket . BinaryMessage , } } }
readPump pumps messages from the websocket connection to the hub.
readPump pumps messages from the websocket connection to the hub .
// c.conn.SetReadLimit(maxMessageSize)