Socket.io XHR support
Created by: ctrox
Hi,
I'm not sure what I'm doing wrong but I'm getting the following error when trying to connect to my socket.io server:
System.err W java.lang.NumberFormatException: Invalid int: "//fonts.googleapis.com/css?family=Open+Sans"
System.err W at java.lang.Integer.invalidInt(Integer.java:138)
System.err W at java.lang.Integer.parse(Integer.java:375)
System.err W at java.lang.Integer.parseInt(Integer.java:366)
System.err W at java.lang.Integer.parseInt(Integer.java:332)
System.err W at com.koushikdutta.async.http.socketio.SocketIOConnection$1.onCompleted(SocketIOConnection.java:112)
System.err W at com.koushikdutta.async.http.socketio.SocketIOConnection$1.onCompleted(SocketIOConnection.java:100)
System.err W at com.koushikdutta.async.http.AsyncHttpClient.invokeWithAffinity(AsyncHttpClient.java:443)
System.err W at com.koushikdutta.async.http.AsyncHttpClient.access$500(AsyncHttpClient.java:40)
System.err W at com.koushikdutta.async.http.AsyncHttpClient$4.run(AsyncHttpClient.java:450)
System.err W at com.koushikdutta.async.AsyncServer.lockAndRunQueue(AsyncServer.java:749)
System.err W at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:760)
System.err W at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
System.err W at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
System.err W at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)
I'm using a very simple socket.io server (the one from the socket.io site):
var io = require('socket.io').listen(8080);
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
It works fine when connecting from a webbrowser.
And this is the Android code I'm using (pretty much taken from the readme):
SocketIOClient.connect(AsyncHttpClient.getDefaultInstance(), wsuri, new ConnectCallback() {
@Override
public void onConnectCompleted(Exception ex, SocketIOClient client) {
if (ex != null) {
Log.i(TAG, "ex is not null!");
ex.printStackTrace();
return;
}
client.setStringCallback(new StringCallback() {
@Override
public void onString(String string, Acknowledge acknowledge) {
System.out.println(string);
}
});
client.setJSONCallback(new JSONCallback() {
@Override
public void onJSON(JSONObject json, Acknowledge acknowledge) {
System.out.println("json: " + json.toString());
}
});
}
});
I'm not sure if I'm doing something wrong here. I tried it yesterday with version 1.1.3 and today with the new 1.1.4.
Thanks!