Event callback in socket client














































Event callback in socket client



When a server broadcasts an event to a client, there is an option for a callback function that may be used to let the client know that the server has processed the event.

 

Although this is entirely managed by the server, the client can provide a list of return values to be provided to the callback function that has been set up.

Simply having the handler function return the desired values achieves this:.

 

@sio.event

def my_event(sid, data):

    # handle the message

return "OK", 123

 

The wait() method can be used by an application if it has nothing to do in the main thread and just wishes to wait until the server connection is broken


Comments