How do I know which client is calling a "run on server" event?

I want to send information from the client to the server AND know which client is calling the event.

As an example, the player sends a notification to the server “my name is John”. How does the server know which player controller should be called John?

Every Actor has Client side and Server side. If you send a variable from the Client side to the Server side (via “Run on Server”) the execution is still within the same Actor. Therefore calling “Get Controller” should give you the same Controller on Client and on Server. If you want get the Player Controller of another Actor you should pass a reference of the Controller by “Run on Server” event.

Here at page 8 you have a nice visualization of how classes are connected in UE network framework.

The thing to note about replication is that some things exist only on the client, some things only on the server, and some are duplicated between the server and client, with the server most often having the authorative version.

So in your case, it depends on where you send that event from. You mentioned player controller, so I’ll assume that is where you put the event. The server holds a player controller for each connected player, while the client only has his own. So when you call run on server on that clients player controller, that event is run on the servers version of that particular player controller. It will not run on EVERY player controller that the server holds. So if you get a reference to self at that point, it will point to the servers version of the player controller. But UE also knows that it is being replicated to a certain connected client, so you can add a “Run on owning client” event. That makes whatever comes next fire on the clients version of that particular player controller.

So in your case all you need to do is: Run on Server > Set NameString = “John”. Now NameString is John on the server. If the NameString variable is replicated, the client will see the update as well, otherwise you’d have to run on owning client with the same Set NameString = “John” after that.

Hope that cleared things up a bit!