Commit Graph

2605 Commits

Author SHA1 Message Date
James Frowen
8e772a2077
fix(weaver): Fixing weaver not writing when assemble didn't have NetworkBehaviour (#2373)
* Making ReaderWriterProcessor return if it found custom functions (not counting ones in mirror.dll)
* Always writing generateContainerClass if modified
* processing PropertySiteProcessor if either ReaderWriterProcessor or WeaveModule are successful
* creating generateContainerClass in WeaverList constructor
* Moving new WeaverList to after WeaverTypes.SetupTargetTypes
2020-10-26 15:51:38 +01:00
James Frowen
4efd19c4ff
feat: Middleware transport (#2362)
* feat: adding MiddlewareTransport

* Allows Middleware to be created at the transport layer
* Middleware can choice which methods they want to override and which to let inner handle

* using expression bodies
2020-10-25 21:42:00 +01:00
MrGadget1024
4628685a62 fixed outdated comment 2020-10-25 15:25:34 -04:00
MrGadget1024
8c08ecf84d Empty braces on same line 2020-10-25 13:44:07 -04:00
MrGadget
75ce277a68
Add Accept and Reject methods to Authenticator (#2370)
* Add Accept and Reject methods to Authenticator

* Tabs To Spaces

* Removed `base.`

Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-25 12:55:29 -04:00
James Frowen
b19a8ccd12 fix(SimpleWebTransport): making sure that ReadHelper.Read reads exactly number of bytes
Docs say that stream.Read could return less than length. Keep reading stream untill length is reached.
2020-10-25 16:05:35 +00:00
James Frowen
414030d023
fix: making ClientAuthorityCallback an event (#2363)
* stops error prone behaviour of using = from multiple scripts

BREAKING CHANGE: `= callback` now needs to be `+= callback`
2020-10-25 17:01:53 +01:00
MrGadget
8f4ff423cb
Basic Authenticator code organization and comments (#2369)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-25 09:52:16 -04:00
James Frowen
a833f5c29f
Running code clean up (#2364)
* removing un-needed using
* whitespace
* using explicit types
2020-10-24 20:24:54 +01:00
James Frowen
28fc75140c
fix: improving errors in SendTargetRPCInternal (#2358)
* fix: improving errors in SendTargetRPCInternal

* now give error when connection is null
* updating error message to accurately explain what went wrong
2020-10-24 20:18:59 +01:00
MrGadget
77c844184e
Remove Obsoletes (#2361)
BREAKING CHANGE: Removed Obsolete Methods and Tests
2020-10-24 11:36:44 -05:00
MrGadget1024
60bc1555a5 Added Deprecated date to SyncList 2020-10-24 11:37:54 -04:00
MrGadget
749c9ee970
Make SerializeSyncVars & DeserializeSyncVars protected virtual (#2360)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-24 16:18:31 +02:00
MrGadget
cf3cf6a1ab
Remove EditorBrowsable Never Attributes (#2359)
Co-authored-by: MrGadget1024 <chris@clevertech.net>
2020-10-24 16:18:05 +02:00
James Frowen
0c6b63a2b1 simpleweb refactor changes 2020-10-22 19:13:58 +01:00
vis2k
d940db7e65 fix: #2357 (the second bug): NetworkServer.DisconnectAllConnections now iterates a copy of connections.Values to InvalidOperationException in cases where Transport.ServerDisconnect calls Mirror's OnServerDisconnect event immediately, which calls NetworkServer.OnDisconnected(connectionId), which would remove the connection while DisconnectAllConnections is iterating over them. 2020-10-22 11:36:18 +02:00
James Frowen
06ae90878d
Removing IDisposable from NetworkConnection (#2345)
* clientOwnedObjects is a hash set which doesn't need to be disposed
* DestroyOwnedObjects already clears list which is called by networkmanager when connection disconnects

Co-authored-by: vis2k <info@noobtuts.com>
2020-10-22 09:50:37 +02:00
James Frowen
46d8077780
Simplifing IsClientAlive check (#2346)
* moving check to base connection because it could be used for either
* renaming to IsAlive
* passing in timeout so it doesn't need to check NetworkServer
* updating doc comment
2020-10-22 09:48:35 +02:00
Chris Langsenkamp
2439af8c5e Applied Mirror Icon 2020-10-21 17:56:14 -04:00
vis2k
d3f1ee9819 fix: NetworkClient.Disconnect avoids NullReferenceException if Transport ClientDisconnect calls OnDisconnected immediately. Related to: https://github.com/vis2k/Mirror/issues/2353 2020-10-21 20:41:40 +02:00
Paul Pacheco
71dc3a2481 fix: recursive types with collections 2020-10-20 09:47:43 -05:00
Paul Pacheco
3bf41c89ea
simplify serializing collections (#416) (#2348)
The code to serialize lists, arrays, and array segments is now in the runtime instead of generated in the weaver.

removes about 300 LOC of weaver witchcraft
2020-10-20 09:47:00 +02:00
James Frowen
c789e2a510
using null propagation for RemoveOwnedObject (#2347) 2020-10-20 01:33:20 +01:00
James Frowen
25be44840e
checking if incoming message has length 0 before checking its id (#2336) 2020-10-18 23:07:10 +02:00
James Frowen
5eac88aa38 feat: adding NetworkRigidbody2D (#2322)(#2342)
* using angularVelocitySensitivity
* removing un-needed using
* using vec2 instead of vec3
2020-10-17 20:46:58 +01:00
pitaya4
b0430efa40
Added support for 2D rigidbodies (#2322)
Added `Mirror.Experimental.NetworkRigidbody2D`, which supports 2D rigid bodies instead of regular ones.
2020-10-17 20:24:30 +01:00
Paul Pacheco
ea7594e558
perf: use built in == instead of unity one (#2339)
* perf: use built in == instead of unity one

should be the same performance as #2325 without the complexity

* more readable version

* more readable version
2020-10-17 13:50:38 -05:00
James Frowen
92c7196f69
feat: Adding SimpleWebTransport v0.6.1 to mirror repo (#2323)
* Intial commit

see https://github.com/MirrorNetworking/SimpleWebTransport  for full git histroy

* Update main.yml

Adding SimpleWebTransport to coverage exclusions

* fully ignoring SimpleWebTransport from sonarcloud

SimpleWebTransport has sonarcloud running on its own repo

* using Buffer.BlockCopy

* SimpleWebTransport v0.4.1

* making error messages use LogError (MirrorNetworking/SimpleWebTransport@5f0096c)
* messages with length of 1 can be recieved by the client (MirrorNetworking/SimpleWebTransport@4237fc4)
* stopping un-needed error logs after disconnect (MirrorNetworking/SimpleWebTransport@25ff190)

* updating readme

* SimpleWebTransport v0.5.0

* adding missing warn level to Log.Levels (MirrorNetworking/SimpleWebTransport@0f68498)
* Allowing multiple instances of javascript client (MirrorNetworking/SimpleWebTransport#14) (MirrorNetworking/SimpleWebTransport@cc6e513)

* SimpleWebTransport v0.5.8

* Stopping send error when client disconnects
* Adding buffer pool
* Using ArrayBuffer for receive
* Removing info and verbose logging by default so performance isnt effected in editor or development builds.
* Making WebSocketClientStandAlone use timeouts from inspector
* Removing incorrect header from inspector
* Removing readonly from logger so that it can be set
* Fixing use of Interlocked in buffer pools
* using ManualResetEventSlim
* making Log.Exception always be logged

* SimpleWebTransport v0.6.0

* Trying to fix error when connection is closed
* Increase arraybuffer speed
* Removing shared buffers from server handshake
* Improving debug logging

* fixing code smells

* SimpleWebTransport v0.6.1

* making sure pending connection work when stop serve is called

* removing exception that isnt directly thrown by this method

this breaks docfx for some reason
2020-10-16 16:46:45 +01:00
James Frowen
f3f0403005
Removing websockets from mirror repo (#2268)
* Adding new websocket transport soon that doesn't depend on library
* Code for old transport can now be found here https://github.com/MirrorNetworking/NinjaWebSocketsTransport
* We shouldn't need to replace with empty files from store as having this in project should not break things
2020-10-16 16:46:04 +01:00
James Frowen
a2b64a4d1d
Update cloud readme
making examples a link
2020-10-15 17:57:48 +01:00
vis2k
31758e668f
perf: NetworkIdentity DirtyComponentsMask code removed entirely. OnSerialize now includes the component index as byte before serializing each component. Faster because we avoid GetDirtyComponentsMask() and GetSyncModeObserversMask() calculations. Increases allowed NetworkBehaviour components from 64 to 255. Code is significantly more simple. (#2331)
* perf: NetworkIdentity DirtyComponentsMask code removed entirely. OnSerialize now includes the component index as byte before serializing each component. Faster because we avoid GetDirtyComponentsMask() and GetSyncModeObserversMask() calculations. Increases allowed NetworkBehaviour components from 64 to 255. Bandwidth is now smaller if <8 components, and larger if >8 components. Code is significantly more simple.

* Update Assets/Mirror/Runtime/NetworkIdentity.cs

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-10-13 16:21:06 +02:00
Paul Pacheco
3c82ff0cb2
breaking: Users must initialize synclists (#391) (#2330)
* Users must initialize syncobjects (#391)

Previously we initialized syncobjects, so this is valid:
```cs
public class Pepe : NetworkBehavior {

    public SyncList<int> mylist;
}
```

With this change,  users must initialize their own fields:
```cs
public class Pepe : NetworkBehavior {

    public SyncList<int> mylist = new SyncList<int>();
}
```

BREAKING CHANGE: You must initialize all your SyncLists

* Add null check

* This is no longer a weaver error

* Update Assets/Mirror/Runtime/NetworkBehaviour.cs

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>

* Remove unnecesary using

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-10-12 09:37:26 +02:00
James Frowen
1da023dfd3
Update NetworkIdentity.cs
checking cache instead of property
2020-10-11 22:45:48 +01:00
James Frowen
9bf8817245
fix: fixing Initializer for generic synclists (#2328)
Weaver should initialize `public SyncList<int> myList;`  in the same way it does for `SyncListInt`
2020-10-10 18:04:35 -05:00
James Frowen
ad48d511a1
Update NetworkConnection.cs
reverting comment
2020-10-10 15:34:46 +01:00
James Frowen
1c476f71b5
Update NetworkConnection.cs 2020-10-10 13:04:07 +01:00
vis2k
eb23bb76e0 Benchmark: custom NetworkManager with adjustable spawn amount for easier testing 2020-10-10 12:42:06 +02:00
vis2k
7529f5aedc Benchmark: namespace changed from OneK to Benchmark 2020-10-10 12:39:50 +02:00
vis2k
575f1f6071 Benchmark: SpawnPosition renamed and centered at 0,0,0 2020-10-10 12:39:06 +02:00
uwee
6e44e6e526
fix: NRE in tanks example when running in headless server only (#2326) 2020-10-09 13:23:47 +01:00
vis2k
d9f58d3439 Benchmark monsters doubled to 4k, everyone broadcasting to everyone 2020-10-08 15:19:44 +02:00
James Frowen
5ad3fb5807
feat: NetworkTranform Teleport (#2320)
* Server Teleport Enchancement for NetworkTransform

Related to this issue: https://github.com/vis2k/Mirror/issues/2200

* Improvements on NetworkTransformBase

We disable clientAuthority until teleportation is finished and acknowledged. We set the goal and start data points to null before teleportation.
We set the clientAuthority back to it's initial value registered on server, both on the server and client side; it seems like we don't need to change it to anything on Client side because to my understanding clientAuthortiy is not affecting anything on client side. I may be wrong but still it is a great practice to set it back to it's initial value just in case...

* Added teleportation with rotation

I forgot to add a rotation functionality on my previous commit. It wouldn't be a teleportation without also changing the rotation. If provided a rotation input it will teleport with a rotation, if not it will simply protect the original rotation before the teleportation.

* Removed my debug statement

I forgot to remove the debug log statement lol silly me

* fixing up code

* resetting goal and last pos on server and client
* renaming variables
* making sure TeleportFinished can't request authority at any time

* moving teleport block

* removing duplicate lines

Co-authored-by: Emre Bugday <47198270+EmreB99@users.noreply.github.com>
2020-10-06 18:47:16 +01:00
James Frowen
1b5cbb51d7
fix: fixing PR number in Obsolete message 2020-10-06 18:08:35 +01:00
Paul Pacheco
31b07ae02f
breaking: no need to override Serialize/Deserialize in messages (#2317)
* breaking: no need to override Serialize/Deserialize in messages

Messages no longer serilize themselves.  This has been decoupled.  Serializing a message is now done
via readers and writers, which can be either generated or user provided.

This lifts some restrictions,
* you no longer need to have a default constructor in messages
* Messages types can be recursive
* struct Messages don't need to provide an empty Serialize and Deserialize method

Before:
```cs
public struct ReadyMessage : IMessageBase
{
    public void Deserialize(NetworkReader reader) { }

    public void Serialize(NetworkWriter writer) { }
}
```

After:
```cs
public struct ReadyMessage : IMessageBase
{
}
```

BREAKING CHANGE: Messages must be public
BREAKING CHANGE: Use custom reader and writer instead of Serialize/Deserialize methods

* Remove unused method

* remove unused methods

* remove unused methods

* make all messages struct

* Fix test code generator

* Get rid of MessageBase

* Rename IMessageBase -> NetworkMessage

* add MessageBase as obsolete

* Use a default request

* Empty file to make asset store happy

* Apply suggestions from code review

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>

Co-authored-by: James Frowen <jamesfrowendev@gmail.com>
2020-10-06 09:31:02 +02:00
James Frowen
6813360f93
feat: NetworkAnimator now syncs animator.speed (#2312)
* feat: NetworkAnimator now syncs animator.speed

* Update NetworkAnimator.cs

- adding previous speed field
- avoiding floating number equals

* Update NetworkAnimator.cs

- adding previousSpeed field
2020-10-03 20:51:08 +02:00
Emre Bugday
032012f9e1
Fixed OnStopClient not being called on Client Side (#2308)
* Fixed OnStopClient not being called on Client Side

* Moved identity.OnStopClient() two scopes above

Co-authored-by: Emre Bugday <47198270+EmreB99@users.noreply.github.com>
2020-10-03 02:57:37 +01:00
James Frowen
42f5a117ec
Update Extensions.cs (#2310)
- only catching AssemblyResolutionException
- using null propagation instead of null ref
2020-10-03 01:45:53 +01:00
James Frowen
181bab6bd0
fixing test names (#2309)
* fixing test names

* renaming test files
2020-10-03 01:45:40 +01:00
vis2k
e730e4baca fix tests after previous SyncLists commit 2020-10-02 10:03:07 +02:00
Paul Pacheco
fb49d19793
breaking: Use SyncLists directly (delete overrides) (#2307)
* feat: Use SyncLists directly

Previously,  you had to write an intermediary class to use synclists, syncsets and syncdictionaries.
The weaver would populate that intermediary class with a serialization and deserialization method

This PR gets rid of 90% of the weaver code for synclists.
There is no need to generate these methods anymore.
Instead the lists use `writer.Write<T>` and `read.read<T>` to serialize their Data.

Since there is no code generate in synclists, you can now use the synclists directly instead
of subclassing them.

BEFORE:

```cs
public class MyComponent : NetworkBehaviour {
    // nonsense class to make the weaver happy
    class SyncListData : Synclist<Data> {}

    SyncListData mySyncList;
}
```

AFTER:

```cs
public class MyComponent : NetworkBehaviour {
    Synclist<Data> mySyncList;
}
```

* linting

* feat: Use SyncLists directly (no overrides)

Previously,  you had to write an intermediary class to use synclists and syncdictionaries.

The weaver would populate that intermediary class with a serialization and deserialization method

This PR gets rid of 90% of the weaver code for synclists.
There is no need to generate these methods anymore.
Instead the lists use `writer.Write<T>` and `read.read<T>` to serialize their Data.

Since there is no code generate in synclists, you can now use the synclists directly instead
of subclassing them.

Same as #2305 ,but it removes the deprecated Serialize and Deserialize methods from syncobjects,
This way you get a nice compiler error for the code that no longer works, instead of a warning you might accidentally ignore.

BEFORE:

```cs
public class MyComponent : NetworkBehaviour {
    // nonsense class to make the weaver happy
    class SyncListData : Synclist<Data> {}

    SyncListData mySyncList;
}
```

AFTER:

```cs
public class MyComponent : NetworkBehaviour {
    Synclist<Data> mySyncList;
}
```

BREAKING CHANGE: Serialize and Deserialize methods in synclists don't do anything anymore

* Remove old comment

* Fix compilatio error
2020-10-02 09:12:25 +02:00