DesktopApp.set_ws_validation#

DesktopApp.set_ws_validation(func)#

Validates a WebSocket connection before sending and accepting data.

ToUI uses Flask-Sock for websocket communication. Flask-Sock generates a simple_websocket.ws.Server object when a connection is established. If you wanted to access this object before sending and receiving data, input a function that has one argument ws. This function should either return True or False. If the function returns False, no data will be sent or received using ToUI with the client.

The ws argument is a simple_websocket.ws.Server object which you can learn about in its documentation. You might need to do some testing in order to explore the types of data that you can find in this object.

Parameters:

func (Callable) – A function that validates the Server object. It should have one argument ws and should either return True or False.

See also

flask_sock, simple_websockets