Example 5 Given the function $f(x)=\frac{a x+b}{x^{2}+2}$ has a maximum value of 1 and a minimum value of -2. Find the values of the real numbers $a, i$.

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly. 

Note: It seems there is a typo in the original text. The variable should likely be $b$ instead of $i$. If this is the case, the correct translation would be:

Example 5 Given the function $f(x)=\frac{a x+b}{x^{2}+2}$ has a maximum value of 1 and a minimum value of -2. Find the values of the real numbers $a, b$.
Let $f(x)=y$, then we have
$$
y x^{2}-a x+(2 y-b)=0 .
$$

Considering this as a quadratic equation in $x$, since $x$ can be any real number, the equation must have real roots. Therefore, we have
$$
\Delta=(-a)^{2}-4 y(2 y-b) \geqslant 0,
$$

which simplifies to $y^{2}-\frac{b}{2} y-\frac{a^{2}}{8} \leqslant 0$.
Given that the maximum value of $y$ is 1 and the minimum value is -2, we have $(y-1)(y+2) \leqslant 0$.
Thus, we get $(y-1)(y+2)=y^{2}-\frac{b}{2} y-\frac{a^{2}}{8}$.
By comparing the coefficients on both sides, we obtain
$$
-\frac{b}{2}=1,-\frac{a^{2}}{8}=-2 \text {. }
$$

Solving these equations, we get $a= \pm 4, b=-2$.