I can't use self in a class.It seems that the data of the function after the decorator is the first parameter.
Example:
import socketio
import random
sio = socketio.Client()
class Test:
def __init__(self):
self.uid = random.randint(0, 10)
@sio.on('test')
def test(self, message):
test_message = str(self.uid) + message
print(test_message)
@staticmethod
def run():
sio.connect('ws://127.0.0.1:5000')
sio.wait()
if __name__ == '__main__':
test = Test()
test.run()
Error:
TypeError: test() missing 1 required positional argument: 'message'