Skip to content
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

Support event callback function #5

Open
pyrasis opened this issue Dec 31, 2012 · 3 comments
Open

Support event callback function #5

pyrasis opened this issue Dec 31, 2012 · 3 comments

Comments

@pyrasis
Copy link

pyrasis commented Dec 31, 2012

server-side.js

socket.emit('hello' , {text: 'world'} , function (res) {
    console.log(res);
});

client-side.js

socket.on('hello', function (data, callback) {
  console.log(data.text);
  callback('hello event ok');
});

please support event callback function.

class socketio_events
{
public:
   static void example(socketio_events&, const Value& args, func callback); // <- callback function
};
@ebshimizu
Copy link
Owner

I haven't used this particular feature of socket.io, and I'm not sure I'll have time soon to figure out how the socket.io javascript client deals with this. It would be a very nice feature to have though.

In your example, where does the callback code get executed, client or server side? It looks like maybe the client and server are labeled backwards? It was my understanding that the function(data, callback) was the signature for the server's response to the event. (See "Sending and getting data (Acknowledgements)" on this page http://socket.io/#how-to-use)

@pyrasis
Copy link
Author

pyrasis commented Jan 1, 2013

Yes. http://socket.io/#how-to-use "Sending and getting data (acknowledgements)" this feature.

 socket.on('ferret', function (name, fn) {
    fn('woot');
  });

I want to call the fn. cpp client side.

@asoedarren
Copy link

I hope you could implement reconnect feature, thanks for your effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants