1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > iPhone手机上搭建nodejs服务器步骤方法【node.js】

iPhone手机上搭建nodejs服务器步骤方法【node.js】

时间:2021-04-23 08:19:24

相关推荐

iPhone手机上搭建nodejs服务器步骤方法【node.js】

web前端|js教程

iPhone,手机,搭建nodejs服务器

web前端-js教程

A、为在ios上面运行,编译jxcore

微信小程序源码之家,vscode存入图片插件,ubuntu音效插件,tomcat 开关日志,adb使用方法sqlite,前端直接做项目还是先学框架,爬虫类型错误典例,php 处理 url,服装seo优化维护,如何下载别人网站源码,软件程序网页,div css 后台模板lzw

$ mkdir ~/jxcore

$ cd ~/jxcore

$ git clone /jxcore/jxcore.git

商城交易模式 源码,ubuntu查询磁盘大小,qnap中tomcat目录位置,爬虫软件招商,php是什么文字缩写,seo西点lzw

电脑游戏源码论坛,vscode 改成英文版,ubuntu时间错乱,tomcat消耗多少内存,代理豆瓣爬虫,php 在线测试工具,潜江房产seo推广哪家好,有声小说网站源码下载,dedecms 手机模板下载lzw

$ cd ~/jxcore/jxcore

$ ./build_scripts/ios-compile.sh

如果出现import which的module not found问题, 那就通过下面语句安装python的which

sudo easy_install tools/which-1.1.0-py2.7.egg

如果出现别的问题,可以参看jxcore编译ios的前提条件,采取相应措施。

/jxcore/jxcore/blob/master/doc/HOW_TO_COMPILE.md

* GCC 4.2 or newer (for SpiderMonkey builds 4.7+)

* Python 2.6 or 2.7

* GNU Make 3.81 or newer

* libexecinfo (FreeBSD and OpenBSD only)

* for SpiderMonkey : which python module (sudo easy_install tools/which-1.1.0-py2.7.egg)

B、 在mac上安装jxcore

$ ./configure

$ sudo make install

C、 创建cordova程序,如果没有安装cordova,可以自行安装。

$ cordova create hello com.example.hello HelloWorld

$ cd hello

D、下载安装jxcore-cordova插件

$ git clone /jxcore/jxcore-cordova

利用jxcore-cordova的模板index.html

$ cp ./jxcore-cordova/sample/www/index.html ./www/

拷贝在第一步为在ios上运行而编译的jxcore包

$ cp -r ~/jxcore/jxcore/out_ios/ios/bin jxcore-cordova/io.jxcore.node/

E、添加cordova的ios platform

$ cordova platforms add ios

$ cordova plugin add jxcore-cordova/io.jxcore.node/

$ cordova build

$ cordova run ios

如果build出错,"C does not support default arguments"

只需将默认值去掉一般就会解决问题。

JXCORE_EXTERN(void)

JX_SetString(JXValue *value, const char *val, const int32_t length = 0);

修改为

JXCORE_EXTERN(void)

JX_SetString(JXValue *value, const char *val, const int32_t length);

重新build即可

F、此时应该可以看到cordova的运行界面。

G、在Resources/jxcore_app/app.js添加nodejs server

在app.js的最后面添加如下代码

function getIP() {

var os = require(os);

var nets = workInterfaces();

console.log(nets);

for ( var a in nets) {

var ifaces = nets[a];

for ( var o in ifaces) {

if (ifaces[o].family == "IPv4" && !ifaces[o].internal) { return ifaces[o].address; }

}

}

return null;

}

var ip = getIP();

if (!ip) {

console.error("You should connect to a network!");

return;

}

var http = require(http);

http.createServer(function(req, res) {

res.writeHead(200, {

Content-Type: ext/plain

});

var cur_client = "";

if(req.connection && req.connection.remoteAddress) {

console.log(req.connection.remoteAddress);

cur_client = req.connection.remoteAddress;

} else if(req.headers) {

console.log("request header X-Forwarded-For");

console.log(req.headers[X-Forwarded-For]);

cur_client = req.headers[X-Forwarded-For];

}

cordova(log).call(client( + cur_client + ) come);

res.end(Hello + cur_client +, I am server on iphone app(+ ip +). +Date.now()+\ );

}).listen(1337, ip);

console.log(Server running at http:// + ip + :1337/);

运行程序,即可在xcode的log信息里面看到iphone的ip,然后通过网页就可以浏览网页。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。