接入了 js版 的 实时通信,和 即时对战 sdk
游戏引擎 Cocos Creator
在 web 上调通了,打包Android,不行
Android的权限也加了
即时对战 部分,也添加了如下代码:
if (cc.sys.platform === cc.sys.ANDROID) {
const caPath = cc.url.raw("resources/cacert.pem");
setAdapters({
WebSocket: url => new WebSocket(url, null, caPath)
});
}
=============
实时通信,初始化的时候 log 信息如下:
D/jswrapper: JS: in M_IM [onLoad]
D/jswrapper: JS: in M_VS [onLoad]
D/jswrapper: JS: Activate: 112.15599999999995ms
D/cocos2d-x: In the constructor of HttpClient!
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
D/JniHelper: JniHelper::getJavaVM(), pthread_self() = -893912800
D/JniHelper: JniHelper::getJavaVM(), pthread_self() = -893912800
D/WebSocket.cpp: WebSocket thread start, helper instance: 0xccddb700
D/WebSocket.cpp: NOTICE: Initial logging level 911
D/WebSocket.cpp: NOTICE: Libwebsockets version: 2.1.0 james@James-Chen.local-v3.4-139-gbdcf7f8
D/WebSocket.cpp: NOTICE: IPV6 compiled in and enabled
D/WebSocket.cpp: NOTICE: libev support not compiled in
D/WebSocket.cpp: NOTICE: libuv support not compiled in
D/WebSocket.cpp: NOTICE: Threads: 1 each 1024 fds
D/WebSocket.cpp: NOTICE: mem: platform fd map: 4096 bytes
D/WebSocket.cpp: NOTICE: Compiled with OpenSSL support
D/WebSocket.cpp: NOTICE: mem: per-conn: 376 bytes + protocol rx buf
D/WebSocket.cpp: scheme: wss, host: cn-n1-cell7.leancloud.cn, port: 0, path: /
D/WebSocket.cpp: WARNING: CA Root file isn't set. SSL connection will not peer server certificate
D/WebSocket.cpp: NOTICE: Creating Vhost 'default' port -1, 1 protocols, IPv6 on
D/WebSocket.cpp: NOTICE: lws_protocol_init
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 32
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 29
D/WebSocket.cpp: NOTICE: accepting self-signed certificate
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 24
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 2
D/WebSocket.cpp: onConnectionOpened...: 0xd0638890, client protocols: lc.protobuf2.1, server selected protocol: lc.protobuf2.1
D/jswrapper: JS: [ERROR]: Unhandled promise rejection [object Object]
D/cocos2d-x: create rendererRecreatedListener for GLProgramState
==========
实时对战,初始化的时候,log 信息 如下
D/WebSocket.cpp: scheme: wss, host: cn-n1-cell6.leancloud.cn, port: 5749, path: /
D/WebSocket.cpp: CA file (/data/user/0/org.cocos2d.dunkingmaster/files/cacert.pem) in writable path exists!
D/WebSocket.cpp: NOTICE: Creating Vhost 'default' port -1, 1 protocols, IPv6 on
D/WebSocket.cpp: WebSocket (0xcd6d2c40) Unhandled websocket event: 32
D/WebSocket.cpp: WebSocket (0xcd6d2c40) Unhandled websocket event: 29
D/WebSocket.cpp: WebSocket (0xcd6d2c40) Unhandled websocket event: 24
D/WebSocket.cpp: WebSocket (0xcd6d2c40) Unhandled websocket event: 2
D/WebSocket.cpp: onConnectionOpened...: 0xcd6d2c40, client protocols: , server selected protocol:
D/WebSocket.cpp: closeAsync: WebSocket (0xcd6d2c40) is closing...
D/WebSocket.cpp: Closing websocket (0xcd6d2c40) connection.
D/jswrapper: JS: M_VS connetSev 连接失败
D/jswrapper: JS: [ERROR]: 10002 Websocket send message error state: 1
D/WebSocket.cpp: WebSocket (0xcd6d2c40) Unhandled websocket event: 33
D/WebSocket.cpp: WebSocket (0xcd6d2c40) Unhandled websocket event: 50
D/WebSocket.cpp: WebSocket (0xcd6d2c40) Unhandled websocket event: 4
D/WebSocket.cpp: WebSocket (0xcd6d2c40) onConnectionClosed, state: 2 ...
D/WebSocket.cpp: onConnectionClosed, WebSocket (0xcd6d2c40) is closing by client asynchronously.
D/WebSocket.cpp: WebSocket (0xcd6d2c40) onConnectionClosed DONE!
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 38
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 33
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 50
D/WebSocket.cpp: WebSocket (0xd0638890) Unhandled websocket event: 4
D/WebSocket.cpp: WebSocket (0xd0638890) onConnectionClosed, state: 1 ...
D/WebSocket.cpp: onConnectionClosed, WebSocket (0xd0638890) is closing by server.
D/WebSocket.cpp: WebSocket (0xd0638890) onConnectionClosed DONE!
E/jswrapper: ERROR: Uncaught event disconnect inappropriate because previous transition did not complete, location: src/project.dev.js:0:0
STACK:
[0]fsm.error@src/project.dev.js:9393
[1]anonymous@src/project.dev.js:9456
[2]handleClose@src/project.dev.js:10621
[3]_handleClose@src/project.dev.js:10076
07-18 10:34:20.622 11187-11213/org.cocos2d.dunkingmaster E/jswrapper: [ERROR] (/Applications/CocosCreator1.9.1.app/Contents/Resources/cocos2d-x/cocos/scripting/js-bindings/proj.android/../jswrapper/v8/Object.cpp, 519): Invoking function (0xccde3910) failed!