Socket.IO - Client not yet connected Error

Hi, I want to authenticate between the server and the client. If it does not perform fast verification, the server closes the connection. The SIODelegate::onConnect function never triggered. I’m looking for a solution like this:

void AppDelegate::onConnect(SIOClient* client){
    client->emit("authenticate",CLIENT_TOKEN);
} 

or

while(true){
    if( client->isConnected() ){ client->emit("authenticate",CLIENT_TOKEN); break;} 
} // But this solution cannot be used. The isConnected() function is private.

I found a way. Until better is found.

  this->_client->on("connected",[=](SIOClient *client,const std::string &data){
    this->_ioConnected = true;
    this->_client->emit("authenticate",this->_ioToken);
  });

in javascript

socket.emit('connected', 'true');