Skip to content

how use on('event',arguments...) in cpp? #26

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

Closed
einsitang opened this issue Jun 15, 2015 · 4 comments
Closed

how use on('event',arguments...) in cpp? #26

einsitang opened this issue Jun 15, 2015 · 4 comments

Comments

@einsitang
Copy link

hi, this is my problem
my client cpp code like this :

socket->on("test event",sio::socket::event_listener_aux([&socket,&line](std::string const& name,sio::message::ptr const& data ,bool isAck,sio::message::ptr &ack_resp){
    do something...
}));

my server js code like this :


socket.emit('test event','1','2','3');


so , how can I receive this argument in cpp code ?
or I just change my server code like this : socket.emit('test event',['1','2','3']);
and the client make sure data is flag_array ??

thanks !

@melode11
Copy link
Contributor

  1. you can use sio::socket::event_listener instead of sio::socket::event_listener_aux, you can get message::list from the event argument.
  2. socket.emit('test event',['1','2','3']) also work. Surely you'll receive a array message.

@einsitang
Copy link
Author

I try to use message::list in the code
like this :

socket->on("test event",sio::socket::event_listener_aux([&socket,&line](std::string const& name,sio::message::list const& data ,bool isAck,sio::message::ptr &ack_resp){
    //but when I use data.size() , just 1 , and I sure my socket.io server use like socket.emit('test event','1','2','3');
   // is something wrong?
}));

@melode11
Copy link
Contributor

you need to use sio::socket::event_listener(event& event) to replace sio::socket::event_listener_aux.

@einsitang
Copy link
Author

thanks , is work. 👍

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

No branches or pull requests

2 participants