Parse a control message like {"type":"resize","cols":80,"rows":24}.
| 293 | |
| 294 | /// Parse a control message like {"type":"resize","cols":80,"rows":24}. |
| 295 | bool parseResizeMessage(const String & json, int & cols, int & rows) |
| 296 | { |
| 297 | auto object = parseRootObject(json); |
| 298 | if (!object) |
| 299 | return false; |
| 300 | if (getStringField(object, "type") != "resize") |
| 301 | return false; |
| 302 | |
| 303 | static constexpr int MAX_TERMINAL_DIMENSION = 500; |
| 304 | cols = getIntField(object, "cols", MAX_TERMINAL_DIMENSION); |
| 305 | rows = getIntField(object, "rows", MAX_TERMINAL_DIMENSION); |
| 306 | return cols > 0 && rows > 0; |
| 307 | } |
| 308 | |
| 309 | /// Parse an auth message like {"type":"auth","user":"...","password":"..."}. |
| 310 | /// The "user" field is optional: when omitted or empty, the caller-provided |
no test coverage detected