mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 00:26:39 +00:00
Fixed part of Cpp to Js callback scopes.
This commit is contained in:
@@ -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({
|
||||
|
@@ -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);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user