尝试把建好的游戏Deploy到Decentraland的土地

in HIVE CN 中文社区5 years ago (edited)

image.png


游戏建好后, 接下来就是要 Deploy 上去Decentraland 的土地。 从 @fundurian 介绍的一个中国DCL 社区微信里跟一位叫 Jayson 的朋友借到了一块土地来deploy。 位置在 -40,-140.

Deploy 过程大概如下。

首先,去 scene.json 填写你的土地的 coordinate。

image.png

然后在 terminal 上输入 dcl start 来compile

然后输入 dcl deploy , metamask 就会跳出来, 然后点一下就完成了。
https://play.decentraland.org/?position=-40%2C-140&realm=fenrir-amber


Deploy前必须注意到事项:

如果你的游戏支援多人连线,例如有用 Websocket 去自己的 VPS,由于 play.decentraland 是用 https ,那你的websocket 也必须用 wss 而不是 ws 。 否则chrome browser 会呱呱叫不让你的游戏client 端链接去 你的 VPS。

那要如何从 ws 变 wss 呢, 首先需要有 ssl cert , 那要ssl cert 可以用 letsencrypt.com 提供的 , 但是 letsencrypt 又要你有 domain name 。 我用的 VPS 只给 IP 而已, letsencrypt 不给我用 IP 注册。

那就只好去 godaddy 买一个 domain name。 最便宜 的有 .xyz 一年 1.38 美金而已。

有了domain name 后, 去DNS 那里 set 一下 那个 A Record 指去你的 IP 就搞定了。

然后,ping 那个domain name 看能去到你的 IP 。


这个完成后 , 去VPS 的 Terminal 里用 certbot 去跟 letsencrypt 要 ssl cert ,但不小心被我搞砸了,三次没办妥,letsencrypt 会设一个 rate limit 来防止同一个domain 一直跟它要cert 。 然后需要等一个礼拜后才会reset 。

只好去用别的, 后来找到 zerossl 也可以处理, 只要放一个档案进vps 里, start 一个webserver 让这个file 可以从外面被访问到(用domain name 访问)就可以了。 这个可以暂时随便跑一个 simpleHttpServer host 一下那个file 就完成了。它的系统访问后,你拿到cert 后在卸掉就好了。


拿到 cert 后, 稍微修改一下你的websocket server 成大概这个就完成了。

image.png


当然,根据莫非定律, 该出麻烦的地方还是会出来的, 例如某些网友的browser 或环境 不能访问 port 10200 啦, 有些就不能用 websocket client 访问 Port 80 ,最后我只好两个port 都兼施。

后来又觉得host 在 port 80 要用root 不好, 所以又改成用 port 10200 和 10300 ,然后用iptables 把 外来的80 转成 10200 , 这样跑这个script 就不用 root 了。 因为listen to 10200 和 10300 是高过 1024 的。

image.png

好了,今天就写到这先, 以后有空在分享。

谢谢阅读。

Sort:  

Congratulations @tensaix2j! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You distributed more than 19000 upvotes. Your next target is to reach 20000 upvotes.

You can view your badges on your board And compare to others on the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Support the HiveBuzz project. Vote for our proposal!