diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ff055949ebd..255af92c762 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,14 +8,14 @@ jobs: runs-on: ubuntu-latest # available list of containers here: # https://hub.docker.com/r/unityci/editor/tags?page=1&ordering=last_updated&name=ubuntu-2020.1.17f1-base - container: unityci/editor:ubuntu-2020.1.17f1-base-0.10.0 + container: unityci/editor:ubuntu-2020.3.17f1-base-0.15.0 steps: - name: Activate unity # exit code is 1 for manual activation continue-on-error: true env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE2 }} + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE_2020_3_17 }} run: | echo "$UNITY_LICENSE" | tr -d '\r' > UnityLicenseFile.ulf unity-editor -nographics -logFile /dev/stdout -manualLicenseFile UnityLicenseFile.ulf -quit @@ -27,7 +27,7 @@ jobs: uses: actions/cache@v2 with: path: Library - key: Library-2020.1.17 + key: Library-Library-2020.3.17 - name: Generate Solution run: unity-editor -nographics -logFile /dev/stdout -customBuildName Mirage -projectPath . -executeMethod UnityEditor.SyncVS.SyncSolution -quit @@ -35,7 +35,14 @@ jobs: - name: Install docfx uses: MirageNet/setup-docfx@v1 - - name: Generate API + # Unity2020.3+Linux seems to check for meta data in wrong order, No idea why + # So for metadata we have to run twice so that it correctly finds references to other c# projects + # First run we do without warningsAsErrors, (it will give warning for cref not found) + # Second run we do it with warningsAsErrors, (it should find cref and not give warning) + - name: Generate API 1 + run: docfx metadata --logLevel Warning doc/docfx.json + + - name: Generate API 2 run: docfx metadata --logLevel Warning --warningsAsErrors doc/docfx.json - name: Build Docs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34a73dcd268..1c28e02fff8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,15 +46,15 @@ jobs: apt install -y openjdk-11-jre-headless=11.0.11+9-0ubuntu2~18.04 - name: Run editor Tests - run: unity-editor -nographics -logFile /dev/stdout -runTests -testPlatform editmode -testResults Tests/editmode-results.xml -enableCodeCoverage -coverageResultsPath Tests + run: unity-editor -nographics -logFile /dev/stdout -runTests -testPlatform editmode -testResults Tests/editmode-results.xml -enableCodeCoverage -coverageResultsPath Tests -debugCodeOptimization timeout-minutes: 20 - name: Run play Tests - run: unity-editor -nographics -logFile /dev/stdout -runTests -testPlatform playmode -testResults Tests/playmode-results.xml -enableCodeCoverage -coverageResultsPath Tests + run: unity-editor -nographics -logFile /dev/stdout -runTests -testPlatform playmode -testResults Tests/playmode-results.xml -enableCodeCoverage -coverageResultsPath Tests -debugCodeOptimization timeout-minutes: 20 - name: Archive test results - uses: actions/upload-artifact@v2.2.3 + uses: actions/upload-artifact@v2.2.4 if: always() with: name: Test results @@ -100,6 +100,7 @@ jobs: /d:sonar.verbose=false \ /d:sonar.login=$SONAR_TOKEN \ /d:sonar.host.url=https://sonarcloud.io \ + /d:sonar.exclusions=Assets/Mirage/Runtime/Sockets/Udp/NanoSockets/** \ /d:sonar.cpd.exclusions=Assets/Tests/** \ /d:sonar.coverage.exclusions=Assets/Tests/** \ ${{ steps.semantic.outputs.new_release_published == 'true' && format('/v:{0}',steps.semantic.outputs.new_release_version) || '' }} \ diff --git a/.github/workflows/request-activation-file.yml b/.github/workflows/request-activation-file.yml index fb2d28dc507..d12f1a6f92f 100644 --- a/.github/workflows/request-activation-file.yml +++ b/.github/workflows/request-activation-file.yml @@ -6,17 +6,17 @@ on: jobs: requestActivationFile: runs-on: ubuntu-latest - container: unityci/editor:ubuntu-2020.1.17f1-base-0.10.0 + container: unityci/editor:ubuntu-2020.3.17f1-base-0.15.0 steps: - name: Request manual activation file continue-on-error: true run: unity-editor -logFile /dev/stdout -createManualActivationFile -quit - name: Upload License Request - uses: actions/upload-artifact@v2.2.3 + uses: actions/upload-artifact@v2.2.4 with: name: Manual Activation File - path: Unity_v2020.1.17f1.alf + path: Unity_v2020.3.17f1.alf - name: Next Steps run: | diff --git a/.gitignore b/.gitignore index 3d2a6b69c01..7a6c093275b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Created by weaver tests +Assets/Tests/Weaver/**/CompilationLog.txt + # Created by performance test Assets/StreamingAssets/ Assets/StreamingAssets.meta diff --git a/.releaserc.yml b/.releaserc.yml index b62bccf863c..07e0b4a3566 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -7,6 +7,7 @@ plugins: Assets/Mirage/Authenticators/AssemblyInfo.cs Assets/Mirage/Components/AssemblyInfo.cs Assets/Mirage/Runtime/AssemblyInfo.cs + Assets/Mirage/Editor/AssemblyInfo.cs Assets/Mirage/Runtime/SocketLayer/AssemblyInfo.cs Assets/Mirage/Samples~/AssemblyInfo.cs Assets/Mirage/Samples~/RigidbodyPhysics/Scripts/AssemblyInfo.cs diff --git a/Assets/Mirage/Authenticators/AssemblyInfo.cs b/Assets/Mirage/Authenticators/AssemblyInfo.cs index 1467dac044e..d8c25514ce6 100644 --- a/Assets/Mirage/Authenticators/AssemblyInfo.cs +++ b/Assets/Mirage/Authenticators/AssemblyInfo.cs @@ -1,3 +1,3 @@ ο»Ώusing System.Reflection; -[assembly: AssemblyVersion("96.3.1")] +[assembly: AssemblyVersion("102.0.0")] diff --git a/Assets/Mirage/Authenticators/BasicAuthenticator.cs b/Assets/Mirage/Authenticators/BasicAuthenticator.cs index 6eb9b700d38..483577e0bb2 100644 --- a/Assets/Mirage/Authenticators/BasicAuthenticator.cs +++ b/Assets/Mirage/Authenticators/BasicAuthenticator.cs @@ -33,7 +33,7 @@ public class BasicAuthenticator : NetworkAuthenticator /// /// /// You might want to use an accessToken or passwords. Be aware that the normal connection - /// in mirror is not encrypted so sending secure information directly is not adviced + /// in Mirage is not encrypted so sending secure information directly is not adviced /// /// @@ -53,13 +53,17 @@ struct AuthResponseMessage #region Server Authenticate - /* - This region should is need to validate the client connection and auth messages sent by the client - */ + public override void ServerSetup(NetworkServer server) + { + // register messsage for Auth when server starts + // this will ensure the handlers are ready when client connects (even in host mode) + + server.MessageHandler.RegisterHandler(OnAuthRequestMessage); + } + public override void ServerAuthenticate(INetworkPlayer player) { // wait for AuthRequestMessage from client - player.RegisterHandler(OnAuthRequestMessage); } @@ -107,10 +111,16 @@ IEnumerator DelayedDisconnect(INetworkPlayer player, float waitTime) #region Client Authenticate - public override void ClientAuthenticate(INetworkPlayer player) + public override void ClientSetup(NetworkClient client) { - player.RegisterHandler(OnAuthResponseMessage); + // register messsage for Auth when client starts + // this will ensure the handlers are ready when client connects (even in host mode) + client.MessageHandler.RegisterHandler(OnAuthResponseMessage); + } + + public override void ClientAuthenticate(INetworkPlayer player) + { // The serverCode should be set on the client before connection to the server. // When the client connects it sends the code and the server checks that it is correct player.Send(new AuthRequestMessage diff --git a/Assets/Mirage/Authenticators/TimeoutAuthenticator.cs b/Assets/Mirage/Authenticators/TimeoutAuthenticator.cs index e9bbb2bb901..a74062dbd63 100644 --- a/Assets/Mirage/Authenticators/TimeoutAuthenticator.cs +++ b/Assets/Mirage/Authenticators/TimeoutAuthenticator.cs @@ -40,6 +40,14 @@ private void HandleClientAuthenticated(INetworkPlayer player) ClientAccept(player); } + public override void ServerAuthenticate(INetworkPlayer player) + { + pendingAuthentication.Add(player); + Authenticator.ServerAuthenticate(player); + if (Timeout > 0) + StartCoroutine(BeginAuthentication(player, ServerReject)); + } + public override void ClientAuthenticate(INetworkPlayer player) { pendingAuthentication.Add(player); @@ -49,12 +57,14 @@ public override void ClientAuthenticate(INetworkPlayer player) StartCoroutine(BeginAuthentication(player, ClientReject)); } - public override void ServerAuthenticate(INetworkPlayer player) + public override void ServerSetup(NetworkServer server) { - pendingAuthentication.Add(player); - Authenticator.ServerAuthenticate(player); - if (Timeout > 0) - StartCoroutine(BeginAuthentication(player, ServerReject)); + Authenticator.ServerSetup(server); + } + + public override void ClientSetup(NetworkClient client) + { + Authenticator.ClientSetup(client); } IEnumerator BeginAuthentication(INetworkPlayer player, Action reject) diff --git a/Assets/Mirage/CHANGELOG.md b/Assets/Mirage/CHANGELOG.md index fa59dc2c920..1216a40d8be 100644 --- a/Assets/Mirage/CHANGELOG.md +++ b/Assets/Mirage/CHANGELOG.md @@ -1,3 +1,370 @@ +# [102.0.0](https://github.com/MirageNet/Mirage/compare/v101.10.0...v102.0.0) (2021-09-02) + + +### Features + +* new improved scene manager ([#892](https://github.com/MirageNet/Mirage/issues/892)) ([2a9bdec](https://github.com/MirageNet/Mirage/commit/2a9bdec6887bc67e7f53bb46f13592607b5c72b8)) + + +### BREAKING CHANGES + +* NetworkSceneManager has been re-written, many events and methods now have new names. + +# [101.10.0](https://github.com/MirageNet/Mirage/compare/v101.9.2...v101.10.0) (2021-08-31) + + +### Features + +* attributes to use new vector bit packers ([#905](https://github.com/MirageNet/Mirage/issues/905)) ([149bf5a](https://github.com/MirageNet/Mirage/commit/149bf5adc44f60ad810c2233afceea32c5af2e2a)) + +## [101.9.2](https://github.com/MirageNet/Mirage/compare/v101.9.1...v101.9.2) (2021-08-29) + + +### Bug Fixes + +* fixing namespace for display metrics ([9d3f056](https://github.com/MirageNet/Mirage/commit/9d3f0568943e531474f56852453233e173e3508f)) + +## [101.9.1](https://github.com/MirageNet/Mirage/compare/v101.9.0...v101.9.1) (2021-08-29) + + +### Bug Fixes + +* improving warning message for taking too many objects from pool ([2bc42c5](https://github.com/MirageNet/Mirage/commit/2bc42c512432ece82bf1eabc53ccf65d27e54556)) + +# [101.9.0](https://github.com/MirageNet/Mirage/compare/v101.8.0...v101.9.0) (2021-08-26) + + +### Bug Fixes + +* **NanoSocket:** adding dispose and finalize ([#904](https://github.com/MirageNet/Mirage/issues/904)) ([ca949ea](https://github.com/MirageNet/Mirage/commit/ca949ea15b900ee7d35d180b73e44103ed54d064)) + + +### Features + +* attributes to use new float bit packers ([#896](https://github.com/MirageNet/Mirage/issues/896)) ([273d27c](https://github.com/MirageNet/Mirage/commit/273d27ce03efee81f507def913ce9a906b1a38f2)) + +# [101.8.0](https://github.com/MirageNet/Mirage/compare/v101.7.0...v101.8.0) (2021-08-24) + + +### Features + +* attributes to calculate bit count of a given range ([#902](https://github.com/MirageNet/Mirage/issues/902)) ([1c22ea6](https://github.com/MirageNet/Mirage/commit/1c22ea63217a3206cb0eb41174135e8fc0133138)) + +# [101.7.0](https://github.com/MirageNet/Mirage/compare/v101.6.0...v101.7.0) (2021-08-24) + + +### Features + +* attributes to use zig zag encoding ([#897](https://github.com/MirageNet/Mirage/issues/897)) ([ccef5fb](https://github.com/MirageNet/Mirage/commit/ccef5fb0302ff97d897f17698e53967e014a9a95)) + +# [101.6.0](https://github.com/MirageNet/Mirage/compare/v101.5.1...v101.6.0) (2021-08-22) + + +### Features + +* **serialization:** attribute to set bit size for ints base syncvars ([#882](https://github.com/MirageNet/Mirage/issues/882)) ([1660ca6](https://github.com/MirageNet/Mirage/commit/1660ca690bee0ef58e398d36511233ebd9975188)) + +## [101.5.1](https://github.com/MirageNet/Mirage/compare/v101.5.0...v101.5.1) (2021-08-22) + + +### Performance Improvements + +* adding throw helper methods so that AggressiveInlining works ([#894](https://github.com/MirageNet/Mirage/issues/894)) ([de12166](https://github.com/MirageNet/Mirage/commit/de1216690a1823724fbb6c717d55a80e44784fa5)) + +# [101.5.0](https://github.com/MirageNet/Mirage/compare/v101.4.2...v101.5.0) (2021-08-22) + + +### Features + +* **NetworkVisibility:** adding default implementation for OnRebuildObservers ([2bcf22f](https://github.com/MirageNet/Mirage/commit/2bcf22f26c1e76f0ed28a066a8c8384f8396077a)) + + +### Performance Improvements + +* sending reply id as nullable ([a756389](https://github.com/MirageNet/Mirage/commit/a7563890c49ca0958332f8fb9fedcca5111ed85f)) + +## [101.4.2](https://github.com/MirageNet/Mirage/compare/v101.4.1...v101.4.2) (2021-08-21) + + +### Bug Fixes + +* fixing log message for checking observers for connected player ([99c31c8](https://github.com/MirageNet/Mirage/commit/99c31c8df337c363a2b4a0be9843dcf8fe24913c)) +* fixing mistake in log change ([b090fa2](https://github.com/MirageNet/Mirage/commit/b090fa2f619ec87de4bc1534343e977247de12f5)) + +## [101.4.1](https://github.com/MirageNet/Mirage/compare/v101.4.0...v101.4.1) (2021-08-19) + + +### Bug Fixes + +* **weaver:** fixing dirty bit for syncvar ([b4a837d](https://github.com/MirageNet/Mirage/commit/b4a837dde40da17ce7947b835da7e6b747d14e32)) + +# [101.4.0](https://github.com/MirageNet/Mirage/compare/v101.3.0...v101.4.0) (2021-08-17) + + +### Bug Fixes + +* fixing pong example ([5ccb42e](https://github.com/MirageNet/Mirage/commit/5ccb42e2c9fdc94bc0e2edec7f669a075f89b604)) + + +### Features + +* adding helper classes for packing uint values ([#878](https://github.com/MirageNet/Mirage/issues/878)) ([3c24f67](https://github.com/MirageNet/Mirage/commit/3c24f67dc6140c9c711b26837ea5b9c8220c1cc1)) + +# [101.3.0](https://github.com/MirageNet/Mirage/compare/v101.2.0...v101.3.0) (2021-08-16) + + +### Bug Fixes + +* preparing client objects on connect ([#876](https://github.com/MirageNet/Mirage/issues/876)) ([9789c0b](https://github.com/MirageNet/Mirage/commit/9789c0b5851c8377e13f799f4a437197e801ecac)) +* **SocketLayer:** moving endpoint copy outside of connection ([c19929f](https://github.com/MirageNet/Mirage/commit/c19929f19b110406b85ac11b6c49a365f5d7da39)) + + +### Features + +* adding helper classes for packing float, vector and quaternion ([#847](https://github.com/MirageNet/Mirage/issues/847)) ([410bcd6](https://github.com/MirageNet/Mirage/commit/410bcd6475e851dfd0a63944051f6522662f8e85)) + +# [101.2.0](https://github.com/MirageNet/Mirage/compare/v101.1.0...v101.2.0) (2021-08-10) + + +### Bug Fixes + +* only invoking unspawn even if item was removed from dictionary ([259e8d0](https://github.com/MirageNet/Mirage/commit/259e8d0dc736bf262fd6bde552618bb37daba31e)) +* **NetworkReader:** checking offset when moving bit position ([641b2b0](https://github.com/MirageNet/Mirage/commit/641b2b005ea7fae6afaba98393344e067f530abf)) + + +### Features + +* adding destroy function that takes network identity ([e91f6d3](https://github.com/MirageNet/Mirage/commit/e91f6d34189159cb8d632949d7fceb7071c950f2)) + +# [101.1.0](https://github.com/MirageNet/Mirage/compare/v101.0.2...v101.1.0) (2021-08-06) + + +### Features + +* **peer:** adding scripts to display metrics from peer ([#872](https://github.com/MirageNet/Mirage/issues/872)) ([e7ac06f](https://github.com/MirageNet/Mirage/commit/e7ac06f972e089f53adc4a90ab90ade1fb309f05)) +* adding way to call SendNotify without allocations and example ([#875](https://github.com/MirageNet/Mirage/issues/875)) ([16b3000](https://github.com/MirageNet/Mirage/commit/16b300002a28eff27bbc2d880993fd61271a4ab6)) + +## [101.0.2](https://github.com/MirageNet/Mirage/compare/v101.0.1...v101.0.2) (2021-08-01) + + +### Bug Fixes + +* fixing error message for disconnect ([0b603fe](https://github.com/MirageNet/Mirage/commit/0b603fe9e15fe2d333c869c8ff9cc51a4c27a823)) +* fixing resize buffer so that it uses byte capacity ([927fe95](https://github.com/MirageNet/Mirage/commit/927fe9574e6a28aac15e90bf4ecc8d3172d423b4)) +* fixing resize buffer when new size is greater than double ([972b6d2](https://github.com/MirageNet/Mirage/commit/972b6d2b811e8082504d9da26b1dd36f377c05eb)) +* removing debug logs from resize buffer ([5f3524c](https://github.com/MirageNet/Mirage/commit/5f3524cf92fcc975928288e31bd456b608ca67f1)) + +## [101.0.1](https://github.com/MirageNet/Mirage/compare/v101.0.0...v101.0.1) (2021-07-29) + + +### Bug Fixes + +* making weaver generate serialize functions for nested messages ([#873](https://github.com/MirageNet/Mirage/issues/873)) ([a351222](https://github.com/MirageNet/Mirage/commit/a351222a3a7d2f75404bfebda049ea270f2f4e63)) + +# [101.0.0](https://github.com/MirageNet/Mirage/compare/v100.0.2...v101.0.0) (2021-07-29) + + +### Code Refactoring + +* removing old version of sequencer ([0efe4ba](https://github.com/MirageNet/Mirage/commit/0efe4babede7726a9dc10590b27194924e4ad7b5)) + + +### BREAKING CHANGES + +* removing old version of Sequencer, use version in socket layer instead + +## [100.0.2](https://github.com/MirageNet/Mirage/compare/v100.0.1...v100.0.2) (2021-07-25) + + +### Performance Improvements + +* removing alloc from reliable sends ([00945f3](https://github.com/MirageNet/Mirage/commit/00945f3f310453f5e57e1b6495be125282d3b8c3)) +* removing allocations from SendToMany ([c57f64d](https://github.com/MirageNet/Mirage/commit/c57f64d7695e1bddefb39fa151ac21b5d2176f35)) + +## [100.0.1](https://github.com/MirageNet/Mirage/compare/v100.0.0...v100.0.1) (2021-07-19) + + +### Bug Fixes + +* **NanoSocket:** adding Exception when nanosocket bind fails ([a3028ec](https://github.com/MirageNet/Mirage/commit/a3028ecb06084574cbbb0b10bbd33394d44d94d2)) + + +### Performance Improvements + +* adding native UDP socket (NanoSockets) for supported platforms ([#860](https://github.com/MirageNet/Mirage/issues/860)) ([3f34863](https://github.com/MirageNet/Mirage/commit/3f34863b65325a54d6a4542c7b767fedc1abf406)) +* removing allocations from assert ([5c216de](https://github.com/MirageNet/Mirage/commit/5c216de5411f6ae9e8a7bb14e52323e214be2793)) + +# [100.0.0](https://github.com/MirageNet/Mirage/compare/v99.1.0...v100.0.0) (2021-07-15) + + +### Code Refactoring + +* moving message handling out of networkplayer ([#818](https://github.com/MirageNet/Mirage/issues/818)) ([b2e9d96](https://github.com/MirageNet/Mirage/commit/b2e9d9693471097ac86fabd725bad8aa6b444983)) + + +### BREAKING CHANGES + +* RegisterHandler functions now exist on MessageHandler On Server and Client +* NetworkAuthenticator now use Setup methods that should be used to register messages + +# [99.1.0](https://github.com/MirageNet/Mirage/compare/v99.0.2...v99.1.0) (2021-07-15) + + +### Features + +* **NetworkWriter:** adding method to move position and docs comments ([#861](https://github.com/MirageNet/Mirage/issues/861)) ([35cf3ec](https://github.com/MirageNet/Mirage/commit/35cf3ecbffbb582bad3022b93b6d5c09ab266f48)) + +## [99.0.2](https://github.com/MirageNet/Mirage/compare/v99.0.1...v99.0.2) (2021-07-05) + + +### Bug Fixes + +* fixing syncvar reading when using bools ([31aca8e](https://github.com/MirageNet/Mirage/commit/31aca8e95752628ed3ad0c6d8e415fcce296b817)) + +## [99.0.1](https://github.com/MirageNet/Mirage/compare/v99.0.0...v99.0.1) (2021-07-03) + + +### Bug Fixes + +* adding assembly version to editor asmdef ([5969236](https://github.com/MirageNet/Mirage/commit/5969236f7a0d6e57848e51cb084f824233e367a4)) + + +### Performance Improvements + +* **WelcomeWindow:** using string builder for change log ([4bc10d8](https://github.com/MirageNet/Mirage/commit/4bc10d840890345f79c24082d283b06302f86b82)) + +# [99.0.0](https://github.com/MirageNet/Mirage/compare/v98.0.1...v99.0.0) (2021-07-03) + + +### Performance Improvements + +* replacing network writer with a faster version that can do bit packing ([#805](https://github.com/MirageNet/Mirage/issues/805)) ([3cffa66](https://github.com/MirageNet/Mirage/commit/3cffa662fee2b09fb54f549d42d820300c61ecda)) + + +### BREAKING CHANGES + +* NetworkWriter and NetworkReader have been completely re-written to support bitpacking + +## [98.0.1](https://github.com/MirageNet/Mirage/compare/v98.0.0...v98.0.1) (2021-07-02) + + +### Performance Improvements + +* replacing network writer with a faster version that can do bit packing ([#805](https://github.com/MirageNet/Mirage/issues/805)) ([773c58f](https://github.com/MirageNet/Mirage/commit/773c58f75eb77be2a893398d1e27012ee9ba83e6)) + +# [98.0.0](https://github.com/MirageNet/Mirage/compare/v97.1.2...v98.0.0) (2021-07-02) + + +### Performance Improvements + +* improving how socketlayer handles endpoints ([#856](https://github.com/MirageNet/Mirage/issues/856)) ([59ce7e0](https://github.com/MirageNet/Mirage/commit/59ce7e097d46d7f2cb7eaa01736dde36066396c5)) + + +### BREAKING CHANGES + +* Socket functions now use an interface instead of the EndPoint class, Socket Implementations should create a custom Endpoint class for their socket. + +## [97.1.2](https://github.com/MirageNet/Mirage/compare/v97.1.1...v97.1.2) (2021-07-01) + + +### Performance Improvements + +* **SocketLayer:** adding IEquatable to struct ([f935786](https://github.com/MirageNet/Mirage/commit/f93578641956c17d84f32ab6356887f45974b07d)) + +## [97.1.1](https://github.com/MirageNet/Mirage/compare/v97.1.0...v97.1.1) (2021-06-28) + + +### Bug Fixes + +* **NetworkManagerHud:** adding null check before using server or client ([e4200e0](https://github.com/MirageNet/Mirage/commit/e4200e07b9c424eccda9e8bfb75a743af753ad78)) +* **NetworkManagerHud:** returning to offline menu when server or client is stopped ([6b4c988](https://github.com/MirageNet/Mirage/commit/6b4c98889777cad31d27d8211f8858e4d81bde09)) + +# [97.1.0](https://github.com/MirageNet/Mirage/compare/v97.0.1...v97.1.0) (2021-06-27) + + +### Features + +* **SocketLayer:** adding fragmentation to reliable sending ([#851](https://github.com/MirageNet/Mirage/issues/851)) ([4764294](https://github.com/MirageNet/Mirage/commit/4764294b18a6e20780fe05626bd001f8c63790f8)) + +## [97.0.1](https://github.com/MirageNet/Mirage/compare/v97.0.0...v97.0.1) (2021-06-27) + + +### Bug Fixes + +* fixing first notify not being returned ([#854](https://github.com/MirageNet/Mirage/issues/854)) ([84b7d2e](https://github.com/MirageNet/Mirage/commit/84b7d2e4cf938763772ebedbb5a55e2db0034ff4)) + +# [97.0.0](https://github.com/MirageNet/Mirage/compare/v96.5.2...v97.0.0) (2021-06-27) + + +### Code Refactoring + +* simplifying packet size in config ([#852](https://github.com/MirageNet/Mirage/issues/852)) ([6bc5ab8](https://github.com/MirageNet/Mirage/commit/6bc5ab8e87c9ec6d2a35a836119a4c891a5a173c)) + + +### BREAKING CHANGES + +* BufferSize and MTU replaced by MaxPacketSize + +## [96.5.2](https://github.com/MirageNet/Mirage/compare/v96.5.1...v96.5.2) (2021-06-27) + + +### Bug Fixes + +* fixing typo in error ([063e3b4](https://github.com/MirageNet/Mirage/commit/063e3b472af003eda400b1fcbbe863f63b3de422)) + +## [96.5.1](https://github.com/MirageNet/Mirage/compare/v96.5.0...v96.5.1) (2021-06-27) + + +### Bug Fixes + +* fixing typo in error ([6195108](https://github.com/MirageNet/Mirage/commit/6195108dd84d5e83be3ac25d824d50125fa9510f)) + +# [96.5.0](https://github.com/MirageNet/Mirage/compare/v96.4.3...v96.5.0) (2021-06-23) + + +### Bug Fixes + +* fixing length used for sending unreliable ([821e2d2](https://github.com/MirageNet/Mirage/commit/821e2d28b2a764f834b96696ed6a438af2535f60)) + + +### Features + +* adding send methods for array segment ([ea09c61](https://github.com/MirageNet/Mirage/commit/ea09c61e0c6c67990d05a58529a800a6948728c0)) + + +### Performance Improvements + +* using array segments for sending ([c990952](https://github.com/MirageNet/Mirage/commit/c990952246463282687c2968852dbe1ae36fdb6e)) +* using pool for send notify ([ac000eb](https://github.com/MirageNet/Mirage/commit/ac000eb6c2db50c81831d092c358f9e707954876)) + +## [96.4.3](https://github.com/MirageNet/Mirage/compare/v96.4.2...v96.4.3) (2021-06-23) + + +### Bug Fixes + +* checking if disconnected before packing message ([a76caf1](https://github.com/MirageNet/Mirage/commit/a76caf148540a2c15cc5622362391acfe20b2388)) + +## [96.4.2](https://github.com/MirageNet/Mirage/compare/v96.4.1...v96.4.2) (2021-06-21) + + +### Bug Fixes + +* null checks when types can't be resolved ([#848](https://github.com/MirageNet/Mirage/issues/848)) ([677c792](https://github.com/MirageNet/Mirage/commit/677c7924b85a890f159ee0abfef44363b266f49a)) + +## [96.4.1](https://github.com/MirageNet/Mirage/compare/v96.4.0...v96.4.1) (2021-06-21) + + +### Bug Fixes + +* welcome window fixes ([#845](https://github.com/MirageNet/Mirage/issues/845)) ([a187844](https://github.com/MirageNet/Mirage/commit/a18784451fb8b4711964ee9ef6c19c161a02059b)) + +# [96.4.0](https://github.com/MirageNet/Mirage/compare/v96.3.1...v96.4.0) (2021-06-20) + + +### Features + +* adding attribute to ignore extension method for read writer ([#841](https://github.com/MirageNet/Mirage/issues/841)) ([9494500](https://github.com/MirageNet/Mirage/commit/94945006f48c486482a67a8c114a2fbe32c2aba4)) + ## [96.3.1](https://github.com/MirageNet/Mirage/compare/v96.3.0...v96.3.1) (2021-06-17) diff --git a/Assets/Mirage/Components/AssemblyInfo.cs b/Assets/Mirage/Components/AssemblyInfo.cs index 691d1538f04..c18c8af63f1 100644 --- a/Assets/Mirage/Components/AssemblyInfo.cs +++ b/Assets/Mirage/Components/AssemblyInfo.cs @@ -1,6 +1,6 @@ using System.Reflection; using System.Runtime.CompilerServices; -[assembly: AssemblyVersion("96.3.1")] +[assembly: AssemblyVersion("102.0.0")] [assembly: InternalsVisibleTo("Mirage.Tests.Runtime")] diff --git a/Assets/Mirage/Components/DisplayMetrics.meta b/Assets/Mirage/Components/DisplayMetrics.meta new file mode 100644 index 00000000000..b79b67a52b6 --- /dev/null +++ b/Assets/Mirage/Components/DisplayMetrics.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a8bfb26cf49a79c4abcf04dee6bed2a4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Components/DisplayMetrics/DisplayMetricsAverageGui.cs b/Assets/Mirage/Components/DisplayMetrics/DisplayMetricsAverageGui.cs new file mode 100644 index 00000000000..905e16bff41 --- /dev/null +++ b/Assets/Mirage/Components/DisplayMetrics/DisplayMetricsAverageGui.cs @@ -0,0 +1,100 @@ +using Mirage.SocketLayer; +using UnityEngine; + +namespace Mirage.DisplayMetrics +{ + public class DisplayMetricsAverageGui : MonoBehaviour + { + public Metrics Metrics { get; set; } + + public Rect offset = new Rect(10, 10, 400, 800); + public Color background; + GUIStyle style; + + + + private void Start() + { + style = new GUIStyle(); + var tex = new Texture2D(1, 1); + tex.SetPixel(0, 0, background); + tex.Apply(); + style.normal.background = tex; + } + + private void OnGUI() + { + if (Metrics == null) { return; } + + using (new GUILayout.AreaScope(offset, GUIContent.none, style)) + { + DrawAverage(); + } + } + void DrawAverage() + { + double connectionCount = 0; + + double sendCount = 0; + double sendBytes = 0; + + double sendUnconnectedCount = 0; + double sendUnconnectedBytes = 0; + + double resendCount = 0; + double resendBytes = 0; + + double receiveCount = 0; + double receiveBytes = 0; + + double receiveUnconnectedBytes = 0; + double receiveUnconnectedCount = 0; + + Metrics.Frame[] array = Metrics.buffer; + int count = 0; + for (int i = 0; i < array.Length; i++) + { + if (!array[i].init) + { + continue; + } + + count++; + connectionCount += array[i].connectionCount; + + sendCount += array[i].sendCount; + sendBytes += array[i].sendBytes; + + sendUnconnectedCount += array[i].sendUnconnectedCount; + sendUnconnectedBytes += array[i].sendUnconnectedBytes; + + resendCount += array[i].resendCount; + resendBytes += array[i].resendBytes; + + receiveCount += array[i].receiveCount; + receiveBytes += array[i].receiveBytes; + + receiveUnconnectedBytes += array[i].receiveUnconnectedBytes; + receiveUnconnectedCount += array[i].receiveUnconnectedCount; + } + + GUILayout.Label($"connectionCount: {connectionCount / count:0.0}"); + GUILayout.Space(8); + GUILayout.Label($"sendCount: {sendCount / count:0.0}"); + GUILayout.Label($"sendBytes: {sendBytes / count:0.00}"); + GUILayout.Space(8); + GUILayout.Label($"sendUnconnectedCount: {sendUnconnectedCount / count:0.0}"); + GUILayout.Label($"sendUnconnectedBytes: {sendUnconnectedBytes / count:0.00}"); + GUILayout.Space(8); + GUILayout.Label($"resendCount: {resendCount / count:0.0}"); + GUILayout.Label($"resendBytes: {resendBytes / count:0.00}"); + GUILayout.Space(8); + GUILayout.Label($"receiveCount: {receiveCount / count:0.0}"); + GUILayout.Label($"receiveBytes: {receiveBytes / count:0.00}"); + GUILayout.Space(8); + GUILayout.Label($"receiveUnconnectedCount: {receiveUnconnectedCount / count:0.0}"); + GUILayout.Label($"receiveUnconnectedBytes: {receiveUnconnectedBytes / count:0.00}"); + + } + } +} diff --git a/Assets/Mirage/Runtime/Serialization/TypeConversion.cs.meta b/Assets/Mirage/Components/DisplayMetrics/DisplayMetricsAverageGui.cs.meta similarity index 83% rename from Assets/Mirage/Runtime/Serialization/TypeConversion.cs.meta rename to Assets/Mirage/Components/DisplayMetrics/DisplayMetricsAverageGui.cs.meta index d48d61eb954..99a9f22b753 100644 --- a/Assets/Mirage/Runtime/Serialization/TypeConversion.cs.meta +++ b/Assets/Mirage/Components/DisplayMetrics/DisplayMetricsAverageGui.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8ab6c1ed99802413b9d356645175e225 +guid: fc574a7aad794bb4f92d506123548695 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Mirage/Components/DisplayMetrics/RequestServerMetrics.cs b/Assets/Mirage/Components/DisplayMetrics/RequestServerMetrics.cs new file mode 100644 index 00000000000..ca2f0c988ec --- /dev/null +++ b/Assets/Mirage/Components/DisplayMetrics/RequestServerMetrics.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Mirage.SocketLayer; +using UnityEngine; + +namespace Mirage.DisplayMetrics +{ + public class RequestServerMetrics : MonoBehaviour + { + public NetworkServer server; + public NetworkClient client; + public DisplayMetricsAverageGui displayMetrics; + public bool RequestMetrics = false; + + /// + /// Connections that are requesting metrics + /// + HashSet connections; + private Metrics metrics; + uint lastSendTick; + + private void Start() + { + if (RequestMetrics) + { + client.Connected.AddListener((x) => sendRequest()); + } + + server.Started.AddListener(ServerStarted); + StartCoroutine(Runner()); + } + + private void ServerStarted() + { + connections = new HashSet(); + + server.MessageHandler.RegisterHandler(OnRequestMetricsMessage); + server.Disconnected.AddListener(x => connections.Remove(x)); + } + + private void OnRequestMetricsMessage(INetworkPlayer arg1, RequestMetricsMessage arg2) + { + connections.Add(arg1); + if (metrics == null) + { + metrics = server.Metrics; + lastSendTick = metrics.tick; + } + } + + private void sendRequest() + { + client.MessageHandler.RegisterHandler(OnSendMetricsMessage); + client.Player.Send(new RequestMetricsMessage()); + metrics = new Metrics(); + displayMetrics.Metrics = metrics; + } + + private void OnSendMetricsMessage(INetworkPlayer _, SendMetricsMessage msg) + { + for (uint i = 0; i < msg.newFrames.Length; i++) + { + ulong seq = metrics.Sequencer.MoveInBounds(i + msg.start); + metrics.buffer[seq] = msg.newFrames[i]; + } + } + + [NetworkMessage] + struct RequestMetricsMessage + { + + } + + [NetworkMessage] + struct SendMetricsMessage + { + public uint start; + public Metrics.Frame[] newFrames; + } + + public IEnumerator Runner() + { + while (true) + { + try + { + if (server.Active && connections.Count > 0) ServerUpdate(); + if (RequestMetrics && client.Active) ClientUpdate(); + } + catch (Exception e) + { + Debug.LogException(e); + } + + yield return new WaitForSeconds(0.1f); + } + } + private void ServerUpdate() + { + var msg = new SendMetricsMessage + { + start = lastSendTick, + newFrames = getFrames(lastSendTick, metrics.tick) + }; + + foreach (INetworkPlayer player in connections) + { + player.Send(msg); + } + } + + private Metrics.Frame[] getFrames(uint start, uint end) + { + long count = metrics.Sequencer.Distance(end, start); + // limit to 100 frames + if (count > 100) count = 100; + + var frames = new Metrics.Frame[count]; + for (uint i = 0; i < count; i++) + { + ulong seq = metrics.Sequencer.MoveInBounds(i + start); + frames[i] = metrics.buffer[seq]; + } + + lastSendTick = (uint)metrics.Sequencer.MoveInBounds(start + (uint)count); + + return frames; + } + + private void ClientUpdate() + { + + } + } +} diff --git a/Assets/Mirage/Runtime/Sequencer.cs.meta b/Assets/Mirage/Components/DisplayMetrics/RequestServerMetrics.cs.meta similarity index 83% rename from Assets/Mirage/Runtime/Sequencer.cs.meta rename to Assets/Mirage/Components/DisplayMetrics/RequestServerMetrics.cs.meta index b09a7f3e679..0e2876a486e 100644 --- a/Assets/Mirage/Runtime/Sequencer.cs.meta +++ b/Assets/Mirage/Components/DisplayMetrics/RequestServerMetrics.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dc5e21b720fa04bc8a770b9f3e0a6470 +guid: 0a72d47940bf27744a731a75b77323b4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Mirage/Components/DisplayMetrics/SetDisplayMetrics.cs b/Assets/Mirage/Components/DisplayMetrics/SetDisplayMetrics.cs new file mode 100644 index 00000000000..5fc66d8a6eb --- /dev/null +++ b/Assets/Mirage/Components/DisplayMetrics/SetDisplayMetrics.cs @@ -0,0 +1,29 @@ +using UnityEngine; + +namespace Mirage.DisplayMetrics +{ + public class SetDisplayMetrics : MonoBehaviour + { + public NetworkServer server; + public NetworkClient client; + public DisplayMetricsAverageGui displayMetrics; + + private void Start() + { + if (server != null) + server.Started.AddListener(ServerStarted); + if (client != null) + client.Connected.AddListener(ClientConnected); + } + + private void ServerStarted() + { + displayMetrics.Metrics = server.Metrics; + } + + private void ClientConnected(INetworkPlayer arg0) + { + displayMetrics.Metrics = client.Metrics; + } + } +} diff --git a/Assets/Mirage/Weaver/Logger.cs.meta b/Assets/Mirage/Components/DisplayMetrics/SetDisplayMetrics.cs.meta similarity index 83% rename from Assets/Mirage/Weaver/Logger.cs.meta rename to Assets/Mirage/Components/DisplayMetrics/SetDisplayMetrics.cs.meta index 3f62978c19c..e1c99f42078 100644 --- a/Assets/Mirage/Weaver/Logger.cs.meta +++ b/Assets/Mirage/Components/DisplayMetrics/SetDisplayMetrics.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2a21c60c40a4c4d679c2b71a7c40882e +guid: 7c354427f6a5b2d4e85a2d7b3336615c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Mirage/Components/NetworkManagerHud.cs b/Assets/Mirage/Components/NetworkManagerHud.cs index ec2c5d1495c..0587d5a1f4c 100644 --- a/Assets/Mirage/Components/NetworkManagerHud.cs +++ b/Assets/Mirage/Components/NetworkManagerHud.cs @@ -7,6 +7,7 @@ public class NetworkManagerHud : MonoBehaviour { public NetworkManager NetworkManager; public string NetworkAddress = "localhost"; + public bool DontDestroy = true; [Header("Prefab Canvas Elements")] public InputField NetworkAddressInput; @@ -16,8 +17,14 @@ public class NetworkManagerHud : MonoBehaviour private void Start() { - DontDestroyOnLoad(transform.root.gameObject); + if (DontDestroy) + DontDestroyOnLoad(transform.root.gameObject); + Application.runInBackground = true; + + // return to offset menu when server or client is stopped + NetworkManager.Server?.Stopped.AddListener(OfflineSetActive); + NetworkManager.Client?.Disconnected.AddListener(_ => OfflineSetActive()); } void SetLabel(string value) diff --git a/Assets/Mirage/Components/NetworkProximityChecker.cs b/Assets/Mirage/Components/NetworkProximityChecker.cs index 3788b566586..0d817fc239e 100644 --- a/Assets/Mirage/Components/NetworkProximityChecker.cs +++ b/Assets/Mirage/Components/NetworkProximityChecker.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using Mirage.Logging; using UnityEngine; -using UnityEngine.Profiling; namespace Mirage { diff --git a/Assets/Mirage/Editor/AssemblyInfo.cs b/Assets/Mirage/Editor/AssemblyInfo.cs new file mode 100644 index 00000000000..26c1b65c472 --- /dev/null +++ b/Assets/Mirage/Editor/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Reflection; + +[assembly: AssemblyVersion("99.0.0")] diff --git a/Assets/Mirage/Runtime/Serialization/Compression.cs.meta b/Assets/Mirage/Editor/AssemblyInfo.cs.meta similarity index 83% rename from Assets/Mirage/Runtime/Serialization/Compression.cs.meta rename to Assets/Mirage/Editor/AssemblyInfo.cs.meta index 717f7e90a10..ef7ba0050df 100644 --- a/Assets/Mirage/Runtime/Serialization/Compression.cs.meta +++ b/Assets/Mirage/Editor/AssemblyInfo.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9aa04482b3d27456e97b974b18752f32 +guid: a81b2a9a9ba9b3948a26235d6e127926 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Mirage/Editor/NetworkScenePostProcess.cs b/Assets/Mirage/Editor/NetworkScenePostProcess.cs index cf5ce62a182..fab9ec42d25 100644 --- a/Assets/Mirage/Editor/NetworkScenePostProcess.cs +++ b/Assets/Mirage/Editor/NetworkScenePostProcess.cs @@ -57,7 +57,7 @@ public static void OnPostProcessScene() } // throwing an exception would only show it for one object // because this function would return afterwards. - else logger.LogError("Scene " + identity.gameObject.scene.path + " needs to be opened and resaved, because the scene object " + identity.name + " has no valid sceneId yet."); + else logger.LogWarning("Scene " + identity.gameObject.scene.path + " needs to be opened and resaved, because the scene object " + identity.name + " has no valid sceneId yet."); } } } diff --git a/Assets/Mirage/Editor/WelcomeWindow/Resources/WelcomeWindow.uxml b/Assets/Mirage/Editor/WelcomeWindow/Resources/WelcomeWindow.uxml index 2c1e2cc42ce..30be51156a8 100644 --- a/Assets/Mirage/Editor/WelcomeWindow/Resources/WelcomeWindow.uxml +++ b/Assets/Mirage/Editor/WelcomeWindow/Resources/WelcomeWindow.uxml @@ -1,5 +1,6 @@ - -