Fixed part of Cpp to Js callback scopes.

This commit is contained in:
genxium
2023-01-24 20:00:58 +08:00
parent e21e1b840f
commit 6bc3feab58
7 changed files with 65 additions and 28 deletions

View File

@@ -547,7 +547,7 @@
"array": [
0,
0,
210.43935996345485,
210.53572189052173,
0,
0,
0,

View File

@@ -145,6 +145,16 @@ cc.Class({
JoinIndex: 1,
};
if (cc.sys.isNative) {
window.onUdpMessage = (args) => {
const len = args.length;
const ui8Arr = new Uint8Array(len);
for (let i = 0; i < len; i++) {
ui8Arr[i] = args.charCodeAt(i);
}
cc.log(`#1 Js called back by CPP: onUdpMessage: args=${args}, typeof(args)=${typeof (args)}, argslen=${args.length}, ui8Arr=${ui8Arr}`);
const echoed = window.pb.protos.HolePunchUpsync.decode(ui8Arr);
cc.log(`#2 Js called back by CPP: onUdpMessage: ${JSON.stringify(echoed)}`);
};
DelayNoMore.UdpSession.upsertPeerUdpAddr(self.selfPlayerInfo.JoinIndex, "192.168.31.194", 6789, 123456);
const res1 = DelayNoMore.UdpSession.openUdpSession(8888 + self.selfPlayerInfo.JoinIndex);
const holePunchDate = window.pb.protos.HolePunchUpsync.encode({

View File

@@ -66,7 +66,9 @@ window.handleHbRequirements = function(resp) {
}
if (window.handleBattleColliderInfo) {
window.initSecondarySession(null, window.boundRoomId);
if (!cc.sys.isNative) {
window.initSecondarySession(null, window.boundRoomId);
}
window.handleBattleColliderInfo(resp.bciFrame);
}
};