Renamed CPP files.

This commit is contained in:
genxium 2023-02-10 11:10:24 +08:00
parent b79e2dc935
commit 365177a3af
10 changed files with 25 additions and 14 deletions

View File

@ -6,9 +6,13 @@ This project is a demo for a websocket-based rollback netcode inspired by [GGPO]
![Merged_cut_annotated_spedup](./charts/Merged_cut_annotated_spedup.gif)
(battle between 2 celluar 4G users using Android phones, [original video here](https://pan.baidu.com/s/1RL-9M-cK8cFS_Q8afMTrJA?pwd=ryzv))
![Phone4g_battle_spedup](./charts/Phone4g_battle_spedup.gif)
As lots of feedbacks ask for a discussion on using UDP instead, I tried to summarize my personal opinion about it in [ConcerningEdgeCases](./ConcerningEdgeCases.md) -- **since v0.9.25, the project is actually equipped with UDP capabilities as follows**.
- When using the so called `native apps` on `Android` and `Windows` (I'm working casually hard to support `iOS` next), the frontends will try to use UDP hole-punching w/ the help of backend as a registry. If UDP hole-punching is working, the rollback is often less than `turn-around frames to recover` and thus not noticeable, being much better than using websocket alone. This video shows how the UDP holepunched p2p performs for [Phone-Wifi v.s. PC-Wifi (viewed by PC side)](https://pan.baidu.com/s/1K6704bJKlrSBTVqGcXhajA?pwd=l7ok).
- If UDP hole-punching is not working, e.g. for Symmetric NAT like in 4G/5G cellular network, the frontends will use backend as a UDP tunnel (or relay, whatever you like to call it). This video shows how the UDP tunnel performs for [Phone-4G v.s. PC-Wifi (viewed by PC side)](https://pan.baidu.com/s/1IZVa5wVgAdeH6D-xsZYFUw?pwd=dgkj).
- If UDP hole-punching is not working, e.g. for Symmetric NAT like in 4G/5G cellular network, the frontends will use backend as a UDP tunnel (or relay, whatever you like to call it). This video shows how the UDP tunnel performs for [Phone-4G v.s. PC-Wifi (merged view@v0.9.34, excellent synchronization)](https://pan.baidu.com/s/1yeIrN5TSf6_av_8-N3vdVg?pwd=7tzw).
- Browser vs `native app` is possible but in that case only websocket is used.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

View File

@ -0,0 +1,7 @@
{
"engine_version": "2.2.1",
"has_native": true,
"project_type": "js",
"projectName": "DelayNoMore",
"packageName": "org.genxium.delaynomore"
}

View File

@ -18,11 +18,11 @@
"from": "cocos/scripting/js-bindings/manual/jsb_module_register.cpp",
"to": "frameworks/runtime-src/Classes/jsb_module_register.cpp"
}, {
"from": "frameworks/runtime-src/Classes/send_ring_buff.hpp",
"to": "frameworks/runtime-src/Classes/send_ring_buff.hpp"
"from": "frameworks/runtime-src/Classes/ring_buff.hpp",
"to": "frameworks/runtime-src/Classes/ring_buff.hpp"
}, {
"from": "frameworks/runtime-src/Classes/send_ring_buff.cpp",
"to": "frameworks/runtime-src/Classes/send_ring_buff.cpp"
"from": "frameworks/runtime-src/Classes/ring_buff.cpp",
"to": "frameworks/runtime-src/Classes/ring_buff.cpp"
}, {
"from": "frameworks/runtime-src/Classes/udp_session.hpp",
"to": "frameworks/runtime-src/Classes/udp_session.hpp"

View File

@ -1,5 +1,5 @@
#include <string.h>
#include "send_ring_buff.hpp"
#include "ring_buff.hpp"
// Sending
void SendRingBuff::put(BYTEC* const newBytes, size_t newBytesLen, PeerAddr* pNewPeerAddr) {
@ -77,7 +77,7 @@ bool RecvRingBuff::pop(RecvWork* out) {
if (0 >= oldCnt) {
// "pop" could be accessed by either "GameThread/pollUdpRecvRingBuff" or "UvRecvThread/put", thus we should be proactively guard against concurrent popping while "1 == cnt"
++cnt;
return NULL;
return false;
}
// When concurrent "pop"s reach here, over-popping is definitely avoided.
@ -99,4 +99,4 @@ bool RecvRingBuff::pop(RecvWork* out) {
++cnt;
return false;
}
}
}

View File

@ -1,7 +1,7 @@
#ifndef udp_session_hpp
#define udp_session_hpp
#include "send_ring_buff.hpp"
#include "ring_buff.hpp"
int const maxPeerCnt = 10;

View File

@ -15,7 +15,7 @@ LOCAL_SRC_FILES := hellojavascript/main.cpp \
../../../Classes/jsb_module_register.cpp \
../../../Classes/udp_session.cpp \
../../../Classes/udp_session_bridge.cpp \
../../../Classes/send_ring_buff.cpp
../../../Classes/ring_buff.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes

View File

@ -190,11 +190,11 @@ copy "$(ProjectDir)..\..\..\project.json" "$(OutDir)\" /Y</Command>
<ClCompile Include="..\Classes\AppDelegate.cpp" />
<ClCompile Include="..\Classes\udp_session.cpp" />
<ClCompile Include="..\Classes\udp_session_bridge.cpp" />
<ClCompile Include="..\Classes\send_ring_buff.cpp" />
<ClCompile Include="..\Classes\ring_buff.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
<ClInclude Include="..\Classes\send_ring_buff.hpp" />
<ClInclude Include="..\Classes\ring_buff.hpp" />
<ClInclude Include="..\Classes\udp_session.hpp" />
<ClInclude Include="..\Classes\udp_session_bridge.hpp" />
<ClInclude Include="..\Classes\AppDelegate.h" />

View File

@ -22,7 +22,7 @@
<ClCompile Include="..\Classes\jsb_module_register.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="..\Classes\send_ring_buff.cpp">
<ClCompile Include="..\Classes\ring_buff.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="..\Classes\udp_session.cpp">
@ -40,7 +40,7 @@
<Filter>win32</Filter>
</ClInclude>
<ClInclude Include="resource.h" />
<ClInclude Include="..\Classes\send_ring_buff.hpp">
<ClInclude Include="..\Classes\ring_buff.hpp">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="..\Classes\udp_session.hpp">