mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 00:26:39 +00:00
Added front-to-back UDP channel punching.
This commit is contained in:
@@ -44,7 +44,7 @@ window.getBoundRoomIdFromPersistentStorage = function() {
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
return null;
|
||||
}
|
||||
const boundRoomIdStr = cc.sys.localStorage.getItem("boundRoomId");
|
||||
const boundRoomIdStr = cc.sys.localStorage.getItem("boundRoomId");
|
||||
return (null == boundRoomIdStr ? null : parseInt(boundRoomIdStr));
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ window.getBoundRoomCapacityFromPersistentStorage = function() {
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
return null;
|
||||
}
|
||||
const boundRoomCapacityStr = cc.sys.localStorage.getItem("boundRoomCapacity");
|
||||
const boundRoomCapacityStr = cc.sys.localStorage.getItem("boundRoomCapacity");
|
||||
return (null == boundRoomCapacityStr ? null : parseInt(boundRoomCapacityStr));
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ window.handleHbRequirements = function(resp) {
|
||||
console.log(`Handle hb requirements #5, web`);
|
||||
window.initSecondarySession(null, window.boundRoomId);
|
||||
} else {
|
||||
console.log(`Handle hb requirements #5, native`);
|
||||
console.log(`Handle hb requirements #5, native, bciFrame.battleUdpTunnel=${resp.bciFrame.battleUdpTunnel}, selfPlayerInfo=${JSON.stringify(window.mapIns.selfPlayerInfo)}`);
|
||||
const res1 = DelayNoMore.UdpSession.openUdpSession(8888 + window.mapIns.selfPlayerInfo.JoinIndex);
|
||||
const intAuthToken = window.mapIns.selfPlayerInfo.intAuthToken;
|
||||
const authKey = Math.floor(Math.random() * 65535);
|
||||
@@ -106,7 +106,12 @@ window.handleHbRequirements = function(resp) {
|
||||
intAuthToken: intAuthToken,
|
||||
authKey: authKey,
|
||||
}).finish();
|
||||
const res2 = DelayNoMore.UdpSession.punchToServer(backendAddress.HOST, 3000, holePunchData);
|
||||
const udpTunnelHolePunchData = window.pb.protos.WsReq.encode({
|
||||
playerId: window.mapIns.selfPlayerInfo.playerId,
|
||||
joinIndex: window.mapIns.selfPlayerInfo.JoinIndex,
|
||||
authKey: resp.bciFrame.battleUdpTunnel.authKey,
|
||||
}).finish();
|
||||
const res2 = DelayNoMore.UdpSession.punchToServer(backendAddress.HOST, 3000, holePunchData, resp.bciFrame.battleUdpTunnel.port, udpTunnelHolePunchData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -3169,6 +3169,7 @@ $root.protos = (function() {
|
||||
* @property {number|null} [ackingInputFrameId] WsReq ackingInputFrameId
|
||||
* @property {Array.<protos.InputFrameUpsync>|null} [inputFrameUpsyncBatch] WsReq inputFrameUpsyncBatch
|
||||
* @property {protos.HeartbeatUpsync|null} [hb] WsReq hb
|
||||
* @property {number|null} [authKey] WsReq authKey
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -3251,6 +3252,14 @@ $root.protos = (function() {
|
||||
*/
|
||||
WsReq.prototype.hb = null;
|
||||
|
||||
/**
|
||||
* WsReq authKey.
|
||||
* @member {number} authKey
|
||||
* @memberof protos.WsReq
|
||||
* @instance
|
||||
*/
|
||||
WsReq.prototype.authKey = 0;
|
||||
|
||||
/**
|
||||
* Creates a new WsReq instance using the specified properties.
|
||||
* @function create
|
||||
@@ -3292,6 +3301,8 @@ $root.protos = (function() {
|
||||
$root.protos.InputFrameUpsync.encode(message.inputFrameUpsyncBatch[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
|
||||
if (message.hb != null && Object.hasOwnProperty.call(message, "hb"))
|
||||
$root.protos.HeartbeatUpsync.encode(message.hb, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim();
|
||||
if (message.authKey != null && Object.hasOwnProperty.call(message, "authKey"))
|
||||
writer.uint32(/* id 9, wireType 0 =*/72).int32(message.authKey);
|
||||
return writer;
|
||||
};
|
||||
|
||||
@@ -3360,6 +3371,10 @@ $root.protos = (function() {
|
||||
message.hb = $root.protos.HeartbeatUpsync.decode(reader, reader.uint32());
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
message.authKey = reader.int32();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
@@ -3427,6 +3442,9 @@ $root.protos = (function() {
|
||||
if (error)
|
||||
return "hb." + error;
|
||||
}
|
||||
if (message.authKey != null && message.hasOwnProperty("authKey"))
|
||||
if (!$util.isInteger(message.authKey))
|
||||
return "authKey: integer expected";
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -3469,6 +3487,8 @@ $root.protos = (function() {
|
||||
throw TypeError(".protos.WsReq.hb: object expected");
|
||||
message.hb = $root.protos.HeartbeatUpsync.fromObject(object.hb);
|
||||
}
|
||||
if (object.authKey != null)
|
||||
message.authKey = object.authKey | 0;
|
||||
return message;
|
||||
};
|
||||
|
||||
@@ -3495,6 +3515,7 @@ $root.protos = (function() {
|
||||
object.ackingFrameId = 0;
|
||||
object.ackingInputFrameId = 0;
|
||||
object.hb = null;
|
||||
object.authKey = 0;
|
||||
}
|
||||
if (message.msgId != null && message.hasOwnProperty("msgId"))
|
||||
object.msgId = message.msgId;
|
||||
@@ -3515,6 +3536,8 @@ $root.protos = (function() {
|
||||
}
|
||||
if (message.hb != null && message.hasOwnProperty("hb"))
|
||||
object.hb = $root.protos.HeartbeatUpsync.toObject(message.hb, options);
|
||||
if (message.authKey != null && message.hasOwnProperty("authKey"))
|
||||
object.authKey = message.authKey;
|
||||
return object;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user