def __init__(self):
### irrelevant initialization of gtk ###
self.sio = socketio.Client()
self.sio.connect('http://localhost:3500')
Process(target=self.sio.wait).start()
### irrelevant initialization of gtk ###
### irrelevant functions for event handlers of gtk ###
# here's the issue. I want to hook up event listeners to the socket
# but i can't access the socket object(?) to put it in the decorator.
# how can i access `self.sio` in here to use it in the decorators?
@sio.on('connect')
def on_connect(self):
print('connection established')
@sio.on('logged in')
def on_message(self, data):
print(data)
print('user id: ', data['user']['id'])
@sio.on('disconnect')
def on_disconnect(self):
print('disconnected from server')
### irrelevant initialization of gtk ###
It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.
ping
Eww.. Using gtk
is your question simply how to use the socketio decorator from the class ?
Обсуждают сегодня