Tuesday 15 September 2015

android - Socket.io client on Google Glass -



android - Socket.io client on Google Glass -

im trying allow google glass , android phone connect nodejs server im running on computer, can send messages android phone google glass.

for im using koush's androidasync library, works great on android phone , have absolutely no problem connecting phone nodejs server library.

however, same code doesnt seem work on google glass. google glass connect, because on connection eventhandler of nodejs server triggered, doesnt seem trigger of connectcallback functions on google glass.

here code im using in google glass app:

socketioclient.connect(asynchttpclient.getdefaultinstance(), "http://192.168.1.229:5000", new connectcallback() { @override public void onconnectcompleted(exception ex, socketioclient client) { log.i("socket", "connection completed"); if (ex != null) { ex.printstacktrace(); return; } client.setstringcallback(new stringcallback() { @override public void onstring(string string, acknowledge acknowledge) { log.d("socket", string); } }); client.setjsoncallback(new jsoncallback() { @override public void onjson(jsonobject jsonobject, acknowledge acknowledge) { log.d("socket", jsonobject.tostring()); } }); client.on("event", new eventcallback() { @override public void onevent(jsonarray jsonarray, acknowledge acknowledge) { log.i("data: ", jsonarray.tostring()); gson gson = new gson(); } }); mclient = client; } });

}

as can see, im trying log "connection completed" in "onconnectcompleted" function, never fires , nil ever logged.

i find rather strange, same code work on android phone , "connection completed" logged when run bit of code on android phone. strangest thing node server picks google glass on connection event triggered on server when glass connects.

so, can help me find out why google glass apparently connecting nodejs server, not triggering events when connects. (not triggering connectcallback functions, "connection completed" never logged)?

thanks in advance,

bram

i facing same issue here , noticed although glass showed connected wifi network, wasn't. tried adb shell netcfg on , surprise wlan0 interface had no ip assigned. reconnected wifi network 1 time again , started work fine.

the weird thing though expecting sort of error logged (even though using different socket.io client). believe case timeout didn't expire (connection/socket timeout) still attempting connect , didn't fail in time see log entry. guess these libraries have relatively high connection timeout set default, wouldn't see error before many seconds go by.

android node.js socket.io google-glass androidasync-koush

No comments:

Post a Comment