-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have no idea why this simple code isn't working. #204
Comments
I was able to get to the data by adding an 'on_event' handler to my client. def on_event(self, event, *args):
super(RFIDNamespace, self).on_event(event, *args)
print ('CLIENT: on_event', event, args) This is a kludge, of course, because what's the point of having defined callbacks if they don't fire with data being passed to them (problem is with the client library, not Flask-SocketIO). I was pretty much following your example code verbatim and it didn't work as expected. At least I can move forward by testing the 'event' variable to see if it was 'on_tag_gained' or 'on_tag_lost'. |
@ilovetogetspamed two ways can be followed to call defined callbacks Case 1: if we are defining the custom_call_back event name other_than default call_back names. then there is a need for explicitly defining the call_back_names like below.
case 2: just rename the method-names
same for "on_tag_lost_response" to "on_tag_lost" |
OK , Thanks, I’ll try that.
… On Dec 11, 2018, at 4:08 AM, lohithNCB ***@***.***> wrote:
@ilovetogetspamed <https://github.com/ilovetogetspamed> two ways can be followed to call defined callbacks
Case 1: if we are defining the custom_call_back event name other_than default call_back names. then there is a need for explicitly defining the call_back_names like below.
`class RFIDNamespace(BaseNamespace):
def on_tag_gained_response(self, *args):
print("tag-----------gain---------response------------")
print('CLIENT: on_tag_gained_response', args)
def on_tag_lost_response(self, *args):
print("tag----------------lost-----------response------")
print('CLIENT: on_tag_lost_response', args)
def on_disconnect(self):
print('CLIENT: disconnected')
def on_connect(self):
print('CLIENT: connected')
# def on_event(self, event, *args):
# super(RFIDNamespace, self).on_event(event, *args)
# print('CLIENT: on_event here i am', event, args)
socketIO = SocketIO('127.0.0.1', 10001)
rfid_namespace = socketIO.define(RFIDNamespace, '/rfid')
rfid_namespace.emit('tag_gained', {'tag': 'operator'})
rfid_namespace.on('tag_lost', rfid_namespace.on_tag_lost_response)
rfid_namespace.emit('tag_lost', {'tag': 'operator'})
rfid_namespace.on('tag_gained', rfid_namespace.on_tag_gained_response)
socketIO.wait(seconds=1)
rfid_namespace.disconnect()
`
case 2:
which is exactly what you were expecting. i.e triggering the defined call-backs on its own.
just rename the method-names
#from
def on_tag_gained_response(self, *args):
print("tag-----------gain---------response------------")
print('CLIENT: on_tag_gained_response', args)
#to
def on_tag_gained(self, *args):
print("tag-----------gain---------response------------")
print('CLIENT: on_tag_gained_response', args)
same for "on_tag_lost_response" to "on_tag_lost"
doing so everything should work as expected... :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#204 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ADHZnCu1JILv05TR3EC2SyphbqGUIAeCks5u33YLgaJpZM4Y8dCy>.
|
I'm having trouble with my on_...._response handlers. They don't seem to get an of the data being sent by the server.
I'm sure I'm doing something wrong and was hoping you could help.
The code is here: https://gist.github.com/ilovetogetspamed/b4e013fd860a8d3cf753205747bb9cb6
I tried it two ways with similar results.
Thanks
The text was updated successfully, but these errors were encountered: