maxFrameSize returns the maximum allowed WebSocket frame size based on the negotiated MaxPayload. This mirrors the server-side wsMaxMessageSize logic.
()
| 188 | // maxFrameSize returns the maximum allowed WebSocket frame size based on the |
| 189 | // negotiated MaxPayload. This mirrors the server-side wsMaxMessageSize logic. |
| 190 | func (r *websocketReader) maxFrameSize() uint64 { |
| 191 | if r.nc != nil { |
| 192 | mp := r.nc.info.MaxPayload |
| 193 | if mp > 0 && uint64(mp) <= wsMaxMsgPayloadLimit/wsMaxMsgPayloadMultiple { |
| 194 | return uint64(mp) * wsMaxMsgPayloadMultiple |
| 195 | } |
| 196 | } |
| 197 | return wsMaxMsgPayloadLimit |
| 198 | } |
| 199 | |
| 200 | // From now on, reads will be from the readLoop and we will need to |
| 201 | // acquire the connection lock should we have to send/write a control |