It blinks because of the way the html is built. It sends a request every 500ms to GetImages. GetImages returns a short html snippet with the <img> nodes.
At this point it replaces the existing <div> thus removing the existing images.
Now the browsers sends two requests to download the images.
This causes the blinking.
There are two ways to solve it. You can change the JavaScript code to download the images to a hidden div and then replace the two divs.
The second solution is to encode the images directly in the response as base64 strings.
Change GetImages class to:
Sub Class_Globals
Dim su As StringUtils
End Sub
Public Sub Initialize
End Sub
Public Sub Handle(req As ServletRequest, resp As ServletResponse)
For Each ip As String In Main.images.Keys
resp.Write("<p>").Write(ip).Write("</p>")
Dim img() As Byte = Main.images.Get(ip)
resp.Write("<img width=500 height=300 src='data:image/png;base64,") '<--- this tells the browser to decode the base64 images.
resp.Write(su.EncodeBase64(img))
resp.Write("'/img>")
Next
End Sub
You can remove GetImage handler as it is no longer used.