node.js for android,node-for-android

#Node for Android

Overview

Node4Android is a library porting of Node 0.8.8. It's an android library project of Eclipse.

How to build

Build it with Eclipse JUNO

Design

First of all. Node4Android is a part of ShuttlePlay.

ShuttlePlay is designed as a game framework. So fro code you don't need. just remove it.

ShuttlePlay is intended to run a web game on mobile device. It's not a web game client but a

server. The web server is established with node.js code. So for game developer, both to frontend

and backend implementation, javascript knownledge is OK.

LaunchActivity

Defaultly, The Node4Android is launched by "LaunchActivity", please find a sample in

Chinese Chess.

In the first time, LaunchActivity is try to find /res/raw/web.zip, and extract it in

the files folder of your andorid app. The phase is called "deploy"

/res/raw/web.zip should contains these files:

config.prop

node

web

The config.prop defines the game's basic settings.

port -- The HTTP port of the game. http uses 80, but for non-root priviledge app. the port number should bigger than 1024

main -- The main file of node.js code. what should node4android launched.

index -- The main page of local web client should load

runlabel -- The title of the notificaiton bar should used

sdfolder -- The sdcard folder for saving game data.

debug -- if true, debug "main" node.js

LaunchActivity would then launch node.js code by invoking "NodeJsService" interface.

and send intent to let browser in the device to handle the URL link "http://:/"

Finally LaunchActivity finish it self. so actually it's invisible.

LaunchActivity either handle exit event. If it received a intent called "net.shuttleplay.node.ShutDown", it would then

do cleanup and cancel node.js's running.

NodeService

NodeService is backend service for keep node.js web server running and not be killed by system. It would be a foreground

service. Hence user can see a notification on the status bar.

As default the status bar should has an icon, a title and two buttons "about" and "exit". the resource isn't defined in the node4android but it

depends on it host android project. so for the host project, these resource should be provided.

/res/layout/notify.xml -- the layout of the notification bar.

/res/value/strings.xml -- strings, at least should be 3, "app_name", "exit" and "about" buttons' title

for others, please refer to /res folder in project Chinese Chess.

For "about" button, an http request would be sent to "http://:/about.html"

For "exit" button, an intent "net.shuttleplay.node.ShutDown" would be sent, actually it would be handled by LaunchActivity

Beside this, NodeService provide NodeJsService interface to launch and debug node.js.

launchInstance(in String file) -- just like "node file" in command line

debugInstance(in String file) -- just like "node --debug-brk file" in command line.

Please note no other arguments is allowed for these two methods

Node.js porting

The porting just work. And it's not just a porting. I'd add one feature for the node.

process.str2qr(string) -- Convert a string be a png stream of QR code.

To implement this feature, I includes two additional libraries

libpng

qrencode

QR code enable other players' devices connect to the shuttleplay game easier

License

The project is conform MIT License

Contact me

Any comments please send me a mail to zhentao_huang#hotmail.com,

Please replace # with @

Test for images

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值