knowledgecode / WebSocket-for-Android

Cordova/PhoneGap plugin that makes WebSocket available on Android
Apache License 2.0
143 stars 53 forks source link

Can I send Cookie also? #9

Closed ericfong closed 10 years ago

ericfong commented 10 years ago

Thanks for your awesome plugin.

I trying to use it with express.io, https://github.com/techpines/express.io

But it fail and say handshake error.

I debug and find that android client seems forget to send cookie data.

How can I do that ?

knowledgecode commented 10 years ago

Hi,

Thank you for your contribution. It is a bug. I have never tested express.io (socket.io). Please give me some time to fix it.

ericfong commented 10 years ago

I am trying to do something like

client.getCookies().put("connect.sid", "hello");

in jetty websocket client without any success so far.

But seems the collection of cookie WebView about target websocket domain is hard

knowledgecode commented 10 years ago

Hi,

I fixed the problem. Seems that express.io is working with the plugin. Would you try the new version(0.6.0) whether your app works?

ericfong commented 10 years ago

It works! You are amazing!

knowledgecode commented 10 years ago

Thank you for your contribution. If you didn't post the bug report, I would not be able to notice it.

ericfong commented 10 years ago

Just want to inform you that.

express session use cookie and the cookie [connect.sid] won't be auto created when you use websocket to connect to it.

So, my work around is $.get('http://server.com/index.html') to trigger the express (connect) server to add a sessionId for my request. BEFORE websocket handshaking with the server.

knowledgecode commented 10 years ago

Actually, I did the same way when I tested the session example of express.io. I think it is a smart way for get the session cookie.

Thanks a lot.