gcrabtree / react-native-socketio

Not Maintained! A React Native wrapper for both the Swift and Java Socket.Io clients.
MIT License
152 stars 55 forks source link

Sending query strings with connect() #18

Open razvanilin opened 8 years ago

razvanilin commented 8 years ago

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=email@email.com&type=web"});

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

ThangLuuQuoc commented 7 years ago

Same problem with me, please support

jose920405 commented 7 years ago

+1

jose920405 commented 7 years ago

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"} })