- Send/SendTo/Receive/ReceiveFrom NonBlocking extensions.
to encapsulate WouldBlock allocations, exceptions, etc.
allows for reuse when overwriting KcpServer/Client (i.e. for relays).
- KcpClient: Tick/Incoming/Outgoing can now be overwritten (virtual)
- breaking: KcpClient now takes KcpConfig in constructor instead of in Connect.
cleaner, and prepares for KcpConfig.MTU setting.
- KcpConfig now includes MTU; KcpPeer now works with KcpConfig's MTU, KcpServer/Client
buffers are now created with config's MTU.
* breaking: Remove NetworkClient.serverIP
- If we're never going to set it to anything, no reason to have it.
- Transport has no mechanism to return anything for it
Host client hardcodes `address` to "localhost" in both LocalConnectionToServer and LocalConnetionToClient, so obsolete the former telling users to use the latter if they aren't already.
Users can get the endpoint from NetworkManager or Discovery, as they must be doing now since those work and serverIp does not.
* Update main.yml
* fix: kcp2p V1.30 (#3391)
- fix: set send/recv buffer sizes directly instead of iterating to find the limit.
fixes: https://github.com/MirrorNetworking/Mirror/issues/3390
- fix: server & client sockets are now always non-blocking to ensure main thread never
blocks on socket.recv/send. Send() now also handles WouldBlock.
- fix: socket.Receive/From directly with non-blocking sockets and handle WouldBlock,
instead of socket.Poll. faster, more obvious, and fixes Poll() looping forever while
socket is in error state. fixes: https://github.com/MirrorNetworking/Mirror/issues/2733
* Shortened PingWindowSize to get a faster more accurate result. (#3395)
* Shortened PingWindowSize to get a faster more accurate result.
Shortened PingWindowSize to get a faster more accurate result.
It taking too long to calculate the average may look bad to users
* Revert "Shortened PingWindowSize to get a faster more accurate result."
This reverts commit 0a5916b4dc.
* Revert "Shortened PingWindowSize to get a faster more accurate result."
This reverts commit 0a5916b4dc.
* Shortened PingWindowSize to get a faster more accurate result.
Shortened PingWindowSize to get a faster more accurate result.
It taking too long to calculate the average may look bad to users
* Shortened PingWindowSize to get a faster more accurate result.
Shortened PingWindowSize to get a faster more accurate result.
It taking too long to calculate the average may look bad to users, choosing 6 gives us an average of 3 results, where as the previous 10, would wait for 5, it should be a slight visual improvement.
* fix: Use PingWindowSize instead of hardcoded value (#3396)
fix: Use PingWindowSize instead of hardcoded value
* KcpClient: Tick/Incoming/Outgoing can now be overwritten (virtual)
* RunUnityTests - Updated unityVersion
* fix: Write for non-spawned NB only writes 0 netId (fixes: #3399) (#3400)
* Failing test for non-spawned NB writer/reader
* fix: Write for non-spawned NB only writes 0 netId
Instead of writing 0 and component index which does not match what the reader expects (it will stop reading netId is 0)
Fixes#3399
* breaking: Removed old Unity 2018 / 2019_3 compiler defines (#3397)
- we only suppport Unity 2019.4.40 and later LTS releases.
BREAKING: Removed old 2018 / 2019 compiler defines
* RunUnityTests - try different test reporter
* RunUnityTests commented out Archive and Publish temporarily
* RunUnityTests - disable game-ci built-in test reporter
* RunUnityTests - cleanup
---------
Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
Co-authored-by: JesusLuvsYooh <57072365+JesusLuvsYooh@users.noreply.github.com>
Co-authored-by: vis2k <info@noobtuts.com>
Co-authored-by: Robin Rolf <imer@imer.cc>
* Failing test for non-spawned NB writer/reader
* fix: Write for non-spawned NB only writes 0 netId
Instead of writing 0 and component index which does not match what the reader expects (it will stop reading netId is 0)
Fixes#3399
* Shortened PingWindowSize to get a faster more accurate result.
Shortened PingWindowSize to get a faster more accurate result.
It taking too long to calculate the average may look bad to users
* Revert "Shortened PingWindowSize to get a faster more accurate result."
This reverts commit 0a5916b4dc.
* Revert "Shortened PingWindowSize to get a faster more accurate result."
This reverts commit 0a5916b4dc.
* Shortened PingWindowSize to get a faster more accurate result.
Shortened PingWindowSize to get a faster more accurate result.
It taking too long to calculate the average may look bad to users
* Shortened PingWindowSize to get a faster more accurate result.
Shortened PingWindowSize to get a faster more accurate result.
It taking too long to calculate the average may look bad to users, choosing 6 gives us an average of 3 results, where as the previous 10, would wait for 5, it should be a slight visual improvement.
- fix: set send/recv buffer sizes directly instead of iterating to find the limit.
fixes: https://github.com/MirrorNetworking/Mirror/issues/3390
- fix: server & client sockets are now always non-blocking to ensure main thread never
blocks on socket.recv/send. Send() now also handles WouldBlock.
- fix: socket.Receive/From directly with non-blocking sockets and handle WouldBlock,
instead of socket.Poll. faster, more obvious, and fixes Poll() looping forever while
socket is in error state. fixes: https://github.com/MirrorNetworking/Mirror/issues/2733
* Organize WeaverTypes
- Put all NetworkBehaviors together
- Put Writer with Reader
- Put Remote things together
- moved ScriptableObjectType down
* moved NetworkClientConnectionReference up
We always use a specific reader for NB syncvars, so if a custom defined writer handles data differently this leads to data mismatches.
Supporting custom readers for NB syncvars will just lead to too many edge cases and unexpected behaviour, so dont do it (see https://github.com/MirrorNetworking/Mirror/issues/2680#issuecomment-1435093212 for rationale).
Fixes#2680
* perf: Weave in pre-computed function hash for RPCs
Instead of computing it at runtime for every call
See #3381, #3377 and #3375
* Update Assets/Mirror/Editor/Weaver/Processors/CommandProcessor.cs
* Update Assets/Mirror/Editor/Weaver/Processors/RpcProcessor.cs
* Update Assets/Mirror/Editor/Weaver/Processors/TargetRpcProcessor.cs
---------
Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
* feat: InterestManagementBase
A interest management base class that allows more advanced interest management by bypassing the built-in HashSet checks via Rebuild overriding
* Update Assets/Mirror/Core/InterestManagementBase.cs
---------
Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
This cleanup step prepares for InterestManagement classes being able to customize the rebuild logic, but for that we should move it out of the NetworkServer class
* Interpolation off bools for NetworkTransform.
Gives a snap-like effect to position, rotation and scaling.
* Update Assets/Mirror/Components/NetworkTransformBase.cs
* Update NetworkTransformBase.cs
---------
Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
* perf: Use static generic class to cache message id
we can (ab)use c# generics to cache the message id in a static field
this is significantly faster than doing a runtime Dictionary lookup in my testing (16% thread cpu-> ~0.22% for 121 moving nts)
generic classes have separate static fields per type specification, so we can store things per-type there, exactly what we need!
* Obsolete NetworkMessages.GetId
* Update Assets/Mirror/Core/NetworkMessages.cs
* Copy comment from GetId up to the Id field
* wording
---------
Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>
* fix: NetworkWriter - Change MaxStringLength to ushort.MaxValue
- local `realsize` in NetworkReaderExtensions.ReadString changed to ushort with proper casting
- Comments added to NetworkWriterExtensions
- Comments added to NetworkReaderExtensions
- Log output updated in both for consistency
* Added comment
* Changes per request
* feat: Read / Write DateTime
- no UTC conversion...users can do that on their own if they want / need to.
DateTime is a public struct but has no public fields (all properties) so no error is thrown if users try to use it in SyncVar / Cmd / Rpc / NetMsg, but no value is put on the wire and SyncVar hooks don't fire because the client determines no actual value change.
* Added nullable DateTime support
* Removed mysterious using
* Failing generics weaver test for T[]
* fix: weaver doesn't handle generic array field
T[] would cause a NRE:
(0,0): error ----------------------------------------------
(0,0): error Exception :System.NullReferenceException: Object reference not set to an instance of an object.
(0,0): error at Mirror.Weaver.Extensions.IsDerivedFrom(TypeReference tr, Type baseClass) in Mirror\Editor\Weaver\Extensions.cs:line 21
(0,0): error at Mirror.Weaver.Extensions.IsDerivedFrom[T](TypeReference tr) in Mirror\Editor\Weaver\Extensions.cs:line 17
(0,0): error at Mirror.Weaver.SyncObjectProcessor.FindSyncObjectsFields(Writers writers, Readers readers, Logger Log, TypeDefinition td, Boolean& WeavingFailed) in Mirror\Editor\Weaver\Processors\SyncObjectProcessor.cs:line 25
(0,0): error at Mirror.Weaver.NetworkBehaviourProcessor.Process(Boolean& WeavingFailed) in Mirror\Editor\Weaver\Processors\NetworkBehaviourProcessor.cs:line 76
(0,0): error at Mirror.Weaver.Weaver.WeaveNetworkBehavior(TypeDefinition td) in Mirror\Editor\Weaver\Weaver.cs:line 109
(0,0): error at Mirror.Weaver.Weaver.WeaveModule(ModuleDefinition moduleDefinition) in Mirror\Editor\Weaver\Weaver.cs:line 125
(0,0): error at Mirror.Weaver.Weaver.Weave(AssemblyDefinition assembly, IAssemblyResolver resolver, Boolean& modified) in Mirror\Editor\Weaver\Weaver.cs:line 208
(0,0): error ----------------------------------------------
* syntax
* SyncDirection example: increase spacing
* LatencySimulator - User friendly changes.
Changed "ping" to milliseconds, from seconds.
Changed % from 0-1, to 0-100 (previously 1 on slider, meant 100%)
Tooltip adjusted to show a good default value to use, and a worst case scenario value.
* Delete Scene.unity
* Revert "Delete Scene.unity"
This reverts commit 305235f6f4.
* Revert "SyncDirection example: increase spacing"
This reverts commit c2176876cb.
* Revert "syntax"
This reverts commit a668c78f68.
* Tooltip adjustments, also now has default values.
* Update LatencySimulation.cs
---------
Co-authored-by: vis2k <info@noobtuts.com>
this would call OnStartClient for scene objects if .isClient was false.
however, NetworkManager.FinishStartHost calls NetworkServer.SpawnObjects first.
which always sets isClient = true for all scene objects.
this way scene objects without owners can still modify SyncLists in OnStopServer without IsWriteable() throwing an exception about NetworkServer being inactive.
* fix: #3330#2422 SpawnObjects now activates, but does not spawn scene objects with inactive parents
* helper function
* remove old workaround.
identities which aren't active in hierarchy don't have Awake called forcefully anymore.
it's not necessary because the second pass won't spawn them anymore.
* add comments
* Fixes: #3326
- All callers to Reset are either unspawning (disabling) the object or have run a custom UnSpawnHandler
- Sync collections should retain their data in any case because the object may get respawned
- When it is respawned, OnDeserializeAll clears the internal collection and changes lists before adding back the entire payload.
- Users can always call the public Reset on the SyncObject themselves if they want it wiped.
* fixed comment
* fix: NetworkClient DestroyAllClientObjects Before ClearSpawners
- DestroyAllClientObjects needs to be able to call Unspawn handlers
- Fixes: 3334
* Update Assets/Mirror/Core/NetworkClient.cs
Co-authored-by: mischa <16416509+vis2k@users.noreply.github.com>
- KcpPeer.RawInput: fix compile error in old Unity Mono versions
- fix: KcpServer sets up a new connection's OnError immediately.
fixes KcpPeer throwing NullReferenceException when attempting to call OnError
after authentication errors.
- improved log messages
* Move Networktransform OnGUI and gizmos to a common baseclass
* Move networktransform teleportation and reset to common base class
* Move networktransform adding snapshots to common base class
* Move networktransform snapshot construction and application to common base class
* Move networktransform awake, onvalidate and IsClientWithAuthority to common base class