Include player that sent the custom network event
PhaxeNor
When dealing with custom network events, it should also include who sent the event.
So that we can check whether or not the one sent it is allowed to trigger it or not.
If it's a local custom event, sender would just be null. This would also add a layer to make sure that the custom event is only allowed locally.
Log In
Momo the Monster
Merged in a post:
Mark certain network events as "From Master Only"
Jar
Modified clients sending malicious Network Events has been a problem in my multiplayer game worlds. We can already prefix event names with an underscore to prevent them from being invoked from SendCustomNetworkEvent, but some events need to be networked for the purposes of the game, usually invoked by the Master as I give the Master authority over game events like Start Game, Game Over, etc.
It would be nice to have some events only be allowed to be invoked by the Master. For example, similar to how _EventName is discarded if it comes from any other player, maybe __EventName (double underscore?) could be discarded if it comes from any payer other than the master.
Momo the Monster
Merged in a post:
Expose udon networked event source
TapGhoul
It'd be really useful to be able to query what player (VRCPlayerAPI ref) triggered a given networked event - whether as an argument, or an explicit getter on Networking or some other component. Doing so would make designing a number of game-related systems considerably more straightforward.
Could implement it as something like Networking.EventSourcePlayer (or a better name) and have it return null if it's not based off of a networked event, as one idea.
Doing so could double as a way to detect if an event was triggered via network (even if it came from local) or just via local. IMO this state should be set any time an event is called via SendCustomEvent, SendCustomNetworkEvent, SendCustomEventDelayedSeconds or SendCustomEventDelayedFrames, with only SendCustomNetworkEvent setting it to non-null (ideally obeying the current call stack to restore state when SendCustomEvent returns if the original event came from SendCustomNetworkEvent)
Jordo
This would be HUGE, the way I was thinking was even a more naive implementation of having a method signature like "StartGame(VRCPlayerApi sender)" and VRChat filling that sender with the PlayerApi that sent it, and if the signature doesn't have a VRCPlayerApi "sender" then it doesn't do anything, like currently.
This would be HUGE for combating modded clients especially as currently the only solution to combat this is to make a synced something that then triggers the method so you can do an owner check which adds completely unnecessary complexity.
This looks to me like a low effort/high impact feature.
TapGhoul
Jordo My only potential thought when it comes to an implementation with an argument is it may be more confusing for Udon Graph users - do you expose an argument? Do you not? Is this the same as an existing event? Do you need to expose a new type of event?
While for U# this would be nice, and a nice way to segregate networked vs non-networked events to some degree in a less hacky fashion, I do question how confusing it may be to new and existing udon graph users with a change like this. Meanwhile a change like I initially suggested is far more backwards-compatible.
Fax
Merged in a post:
VRCPlayerAPI of who sent the SendCustomNetworkEvent
DrakenStark
This capability allows proper responce to individuals without having to juggle multiple UdonSync variables and deserialization events to act as TCP handshakes when a network event is received. With so much needing to go on at once it makes these network calls at risk of being dropped and becoming quickly unreliable and slow.
This feature would also allow world makers to validate users via other clients instead of every client awkwardly winking at each other and saying, "Trust me, I'm on my own whitelist."
Mitigates issues that come up from a user sending calls over the network that they shouldn't have access to or be capable of.
Reimajo
A better solution for this (and a lot of other usecases) would be to know who sent an event to be able to do this (or other checks) yourself. A public method could have a parameter of type VRCPlayerApi which is then populated by VRChat if this method is called from the network.
Should VRChat go with a different approach, please don't use a weird workaround again like an "underscore" and let us use attributes instead https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/
Jar
Reimajo: Being able to know who sent an event would be even better yes!
Snowdrama
Yeah for sure NetworkEvent should always include the current owner of the object who sent the event. This I think ties pretty closely into the ability to send parameters in custom network events.