20170511 創(chuàng)建
0 直接用pomelo init 創(chuàng)建項(xiàng)目速警,然后開始碗誉。
1 服務(wù)器啟動(dòng)時(shí)看到的錯(cuò)誤:
Option path is not valid
onesec 在 5-3 11:01 回復(fù)Option path is not valid
這個(gè)看起來(lái)是配置路徑不對(duì)
將 https://github.com/NetEase/pomelo/blob/master/lib/connectors/sioconnector.js
此文件替換node_modules/pomelo/*/lib/connectors/sioconnector.js 括勺,即可解決此問題描滔,新版sockect.io用法不正確所致的警告孤荣,官方已修復(fù)隅居,但還沒有publish到npm
2 新添加一個(gè)gate服務(wù)器報(bào)錯(cuò)
WebSocket connection to 'ws://127.0.0.1:3014/' failed: Connection closed before receiving a handshake response
新增服務(wù)器需要在以下幾個(gè)地方注冊(cè):
1止后,adminServer.json
2瞎惫,app.js
app.configure('production|development', 'gate', function () {
app.set('connectorConfig',
{
connector: pomelo.connectors.hybridconnector,
useProtobuf: true
});
});
3 熱更新支持
1.0新特性:https://github.com/NetEase/pomelo/wiki/pomelo-1.0%E6%96%B0%E7%89%B9%E6%80%A7
在1.0正式版本中,提供了handler和remote的熱更新的部分支持坯门。在pomelo1.0正式版中微饥,提供對(duì)handler和remote兩個(gè)目錄中的文件進(jìn)行監(jiān)控,當(dāng)有文件更新時(shí)古戴,系統(tǒng)會(huì)重新load對(duì)應(yīng)的handler和remote服務(wù)欠橘,這時(shí)當(dāng)有新的handler請(qǐng)求和rpc請(qǐng)求進(jìn)入時(shí),系統(tǒng)就會(huì)自動(dòng)執(zhí)行更新后的服務(wù)现恼。但是對(duì)于在非handler和remote目錄的文件就不支持熱更新肃续。熱更新開關(guān)默認(rèn)是關(guān)閉狀態(tài),用戶可以通過配置打開熱更新服務(wù)叉袍。
使用方法:
// handler 熱更新開關(guān)
app.set('serverConfig',
{
reloadHandlers: true
});
// remote 熱更新開關(guān)
app.set('remoteConfig',
{
reloadRemotes: true
});
4 mysql連接失敗
端口問題
參考demo始锚,配置好數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù)默認(rèn)端口3306喳逛,但我的不是瞧捌,于是發(fā)現(xiàn)dao_pool.js中并沒有使用配置文件的端口。
增加一行:
return new Promise(function(resolve, reject){
var client = mysql.createConnection({
host: mysqlConfig.host,
user: mysqlConfig.user,
port: mysqlConfig.port, #這里是數(shù)據(jù)庫(kù)端口润文,
password: mysqlConfig.password,
database: mysqlConfig.database
});
resolve(client);
});
},
注意dao_pool.js由于有報(bào)錯(cuò)姐呐,已經(jīng)替換為新的版本,請(qǐng)見我的上一篇文章典蝌。
5 unity項(xiàng)目報(bào)錯(cuò)找不到pomelo庫(kù)
pomelo-unitychat-socket-master 官網(wǎng)下載的demo項(xiàng)目直接打開就報(bào)錯(cuò)了曙砂。
dll庫(kù)版本不匹配
解決辦法:
1,下載pomelo-unityclient-socket-master
2,打開工程,修改生成配置
3, release版本重新生成dll
4, 新的DLL拷貝到demo項(xiàng)目:pomelo-unitychat-socket-master\Assets\Plugins
5, 這時(shí)發(fā)現(xiàn)報(bào)錯(cuò)已經(jīng)變了骏掀,現(xiàn)在的錯(cuò)誤是:
Assets/scripts/LoginGUI.cs(46,8): error CS1729: The type Pomelo.DotNetClient.PomeloClient' does not contain a constructor that takes
2' arguments
這是demo對(duì)接口的用法不對(duì)鸠澈,照著新的教程修改代碼即可
string host = "127.0.0.1";
int port = 3014;
pc = new PomeloClient();
pc.NetWorkStateChangedEvent += (state) =>
{
Debug.logger.Log("CurrentState is:" + state);
};
pc.initClient(host, port, () => {
Debug.logger.Log("init ok...");
pc.connect(null, (data) =>
{
Debug.logger.Log("connect ok...");
JsonObject msg = new JsonObject();
msg["uid"] = userName;
msg["username"] = "abc";
msg["password"] = "123";
pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
});
});
6, demo的服務(wù)端要對(duì)應(yīng)柱告,都是socket的版本。
https://github.com/NetEase/chatofpomelo-websocket