0

I downloaded the example project from Now.js http://nowjs.com/guide and when I run it I get

Uncaught TypeError: Object # has no method 'distributeMessage'

after attempting to send a message.

Ideas?


Android Socket in same process or separate

I am creating a android app that uses a TCP socket to connect to a server. It continuously receives xml strings from this socket and I need to parse it as it comes. Currently I've implemented the socket in a service in the same process of the application.

I get outofmemory exception sometimes. The xml strings I receive will be around 1-3mb. My question is, will it be more efficient if a run my service in a separate process as my socket constantly needs to work? What is the best way to implement a socket in android which works the app life span?

4

2 回答 2

4

原来这是 PaaS 不支持 websockets 的问题。解决方案只是通过以下方式显式禁用它们:

nowjs.initialize(server, {socketio: {transports: ['xhr-polling', 'jsonp-polling', 'htmlfile']}});

(在#nowjs IRC 中解决)

于 2011-08-13T22:27:30.357 回答
0

我们很难知道这么少的信息。如果您发布代码,我们更有可能知道发生了什么。

查看 nowjs.com 网站上的 hello world 演示,看起来helloworld_server.js您的页面中可能没有包含该文件,因为这distributeMessage()是定义函数的地方。

在这里的演示文件中,helloworld.html 有这一行:

<script src="http://localhost:8080/nowjs/now.js"></script>

但是,演示 tgz 文件不包括该文件。您可能now.js在适当的路径中丢失了。

于 2011-08-13T07:22:35.740 回答