Fix wrong binding of JS this

inside the closure this binds to the WebSocket object rather than to the figure object. I only briefly tested this but its meaning should be apparent.