react-native-socketio icon indicating copy to clipboard operation
react-native-socketio copied to clipboard

Sending query strings with connect()

Open razvanilin opened this issue 9 years ago • 3 comments

This feature seems to be missing from this package. I checked the code and the connect() method doesn't take any parameters.

With pure socket.io you can do something like this: io.connect(socketUrl, {query: "email=" + store.get('profile').email + "&type=pc"})

I tried passing the query string like this: new SocketIO(socketUrl, {query: "[email protected]&type=web"});

The above doesn't work though. I'm not able to get the query string on my server.

razvanilin avatar Sep 03 '16 09:09 razvanilin

Same problem with me, please support

ThangLuuQuoc avatar Dec 05 '16 04:12 ThangLuuQuoc

+1

jose920405 avatar Apr 27 '17 17:04 jose920405

Considering this line of code

if connectParams != nil {
            for (key, value) in connectParams! {
                let keyEsc   = key.urlEncode()!
                let valueEsc = "\(value)".urlEncode()!

                queryString += "&\(keyEsc)=\(valueEsc)"
            }
        }

The correct syntax is ==>

this.socket = new SocketIO('http://localhost:3000', { connectParams: {token: "someToken"} })

jose920405 avatar Apr 27 '17 18:04 jose920405