socket.io-client-cpp icon indicating copy to clipboard operation
socket.io-client-cpp copied to clipboard

cpp client connect with custom path

Open wzzaz opened this issue 5 years ago • 2 comments

on the API

const socket = io('http://localhost', {
  path: '/myownpath'
});

// server-side
const io = require('socket.io')({
  path: '/myownpath'
});

and sio_client.h:

// Client Functions - such as send, etc.
        void connect(const std::string& uri);

        void connect(const std::string& uri, const std::map<std::string,std::string>& query);

        void connect(const std::string& uri, const std::map<std::string,std::string>& query,
                     const std::map<std::string,std::string>& http_extra_headers);

what should i do with cpp client?

wzzaz avatar Nov 27 '20 03:11 wzzaz

@darrachequesne Hi, I'm using this C++ client to connect socket io server as well, and having the same requirement now, any update or plan for this enhancement? Thanks!

echo-qin avatar Nov 10 '22 06:11 echo-qin

Hello As @wzzaz and @echo-qin , i'd like to have some informations.

I've found that in sio_client_impl.cpp ...

const std::string host(uo.get_host());
            // As per RFC2732, literal IPv6 address should be enclosed in "[" and "]".
            if(host.find(':')!=std::string::npos){
                ss<<"["<<uo.get_host()<<"]";
            } else {
                ss<<uo.get_host();
            }

            // If a resource path was included in the URI, use that, otherwise
            // use the default /socket.io/.
            const std::string path(uo.get_resource() == "/" ? "/socket.io/" : uo.get_resource());

Thanks

zefaridator avatar Dec 06 '22 21:12 zefaridator