在谷歌玻璃Socket.io客户端 [英] Socket.io client on Google Glass

查看:293
本文介绍了在谷歌玻璃Socket.io客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着让我的谷歌眼镜和我的Andr​​oid手机连接到我的计算机上运行我是个服务器的NodeJS,这样我可以从我的android手机发送信息到我的谷歌眼镜。

Im trying to let my Google Glass and my android phone connect to a NodeJs server that Im running on my computer, so that I can send messages from my android phone to my Google Glass.

有关此IM使用koush的Andr​​oidAsync库,我的Andr​​oid手机上的伟大工程,我绝对我的手机连接到服务器的NodeJS与此库没有烦恼。

For this Im using koush's AndroidAsync library, which works great on my android phone and I have absolutely no trouble connecting my phone to the NodeJS server with this library.

然而,同样的code似乎没有在我的谷歌眼镜的工作。我的谷歌眼镜不会连接,因为我的的NodeJS上的连接事件处理程序服务器被触发,它只是似乎没有触发任何在我的谷歌眼镜的ConnectCallback功能。

However, the same code doesnt seem to work on my Google Glass. My Google Glass DOES connect, because the on connection eventhandler of my NodeJS server IS triggered, it just doesnt seem to trigger any of the ConnectCallback functions on my Google Glass.

下面:

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

}

正如你所看到的,我试着登录连接完成的,在onConnectCompleted的功能,但它从来没有火灾,没有什么是永远记录下来。

As you can see, Im trying to log "CONNECTION COMPLETED" in the "onConnectCompleted" function, but it never fires and nothing is ever logged.

我觉得这很奇怪,因为相同code我的Andr​​oid手机和连接完成的,在工作的时候我在我的Andr​​oid手机上运行code的该位被记录。最奇怪的是,我的节点服务器实际上拿起谷歌玻璃作为连接上触发事件服务器上时,我的玻璃相连接。

I find this rather strange, as the same code DOES work on my android phone and "CONNECTION COMPLETED" IS logged when I run this bit of code on my android phone. The strangest thing is that my node server actually picks up the Google Glass as the on connection event is triggered on the server when my Glass connects.

所以,任何人可以帮助我找到了为什么我的谷歌眼镜显然是连接到我的服务器的NodeJS,但不会触发任何事件,当它连接。 (不触发ConnectCallback功能,连接完成从未登录)?

So, can anybody help me find out why my Google Glass IS apparently connecting to my NodeJS server, but is NOT triggering any events when it connects. (Not triggering the ConnectCallback functions, "CONNECTION COMPLETED" is never logged)?

由于提前,

布拉姆

推荐答案

我在这里面临着同样的问题,发现虽然我的玻璃显示出它是连接到我的WiFi网络,但实际上并非如此。我试图亚行外壳加上netcfg 它,让我吃惊的为wlan0 接口没有分配的IP。我再次重新连接到WiFi网络,这一切开始工作就好了。

I was facing the same issue here and noticed although my Glass showed it was connected to my Wifi network, it actually wasn't. I tried adb shell netcfg on it and to my surprise the wlan0 interface had no IP assigned. I reconnected it to the wifi network again and it all started to work just fine.

奇怪的是,虽然我期待某种错误将被记录(即使我使用的是不同的 Socket.IO客户端)。我相信的情况下是没有到期(连接/套接字超时),所以它仍然试图连接,并在一段时间没有失败我们看到的日志条目超时。我猜这些库具有比较高的连接超时默认设置,所以你不会看到一个错误之​​前多少秒就会去了。

The weird thing though is that I was expecting some sort of error to be logged (even though I was using a different Socket.IO client). I believe the case to be a timeout that didn't expire (connection/socket timeout) so it was still attempting to connect and didn't fail in time for us to see the log entry. I guess these libraries have a relatively high connection timeout set by default, so you wouldn't see an error before many seconds would go by.

这篇关于在谷歌玻璃Socket.io客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆