This confuses me a bit. Isn’t this supposed to be taken care of by replication? You shouldn’t have to go through and manually update each clients chat structure, right? If the chat array is replicated, then as soon as the server updates the chat data, the data gets replicated to the clients. All the clients would need is a “RepNotify” event so that they can refresh their GUI with the latest chat data with the latest replicated data from the server. That’s how I’ve got it working on mine…
I guess I’m trying to wrap my head around how the server/client relationship works. The chat system is just a test of my understanding here.
To my understanding, the server is the authority on the whole state of the game and their actors. In “model-view-controller” terms, the server hosts the definitive model. Clients are viewers of the server model and they can interact with the model by using controllers. Clients will build a copy of the model on their local machine, but the copy is not the definitive model. If the client wants to interact with the model and make a change to it, they send a message to the server via RPC. The server then gets to validate that message and decide if the client request is legit. Such as, “Move my character forward by 10 feet.”. If the request is validated, the server then processes the request by making a change to the authoritative game model. That change then gets replicated to all clients, and they update their local copy of the game state.
Sometimes the server will want to send out a message to all connected clients, such as “This bomb has exploded, play a particle effect at its location.”. This is when a non-reliable multicast message would be handy.
In the case of my chat system, here’s where UE4 replication gets funky:
-In order for an object to be replicated, it MUST be an actor.
> “What?! What if I don’t want any of the memory overhead which comes with actors? I just want to have a replicated array of strings.”
> “Too bad, put it into an actor. Besides, don’t worry about it.”
-You can only make a change to an object if you are the network owner of it.
> “Okay, fine. The server owns everything and clients have to ask the server to change those objects.” Except the server says, “I own this object, you can’t change it! your RPC request is denied!”
Here’s what should happen:
Server: “Hey clients, here is the current list of chat messages! I’m maintaining and replicating its data to you.”
**Clients: **“Thanks, we’ll refresh our gui to display them to players!”
Client X: “Hey Server, I’d like to add a message to the chat with the following string: ‘hello world’”.
Server: “Okay, that sounds legit. I’ll add it to my array of chat messages.”
Server: “Hey all clients, the chat messages have been updated! Make sure you refresh your GUI to display the updated info! It’s already been automatically replicated to your local copy.”
**Clients: **“Thanks! Got it! Refreshing GUI now.”
Client X: “Hey, I’d like to add this spam message to the chat.”
Server: “Whoa, hold on there. It’s been 0.1 seconds since your last chat message and this is the same one as last time. Denied!”
Client X: “Dang :(”
Instead, here’s what happens:
**Server: **“Hey clients, here is the current list of chat messages! I’m maintaining and replicating its data to you.”
**Clients: **“Thanks, we’ll refresh our gui to display them to players!”
**Client X: **“Hey Server, I’d like to add a message to the chat with the following string: ‘hello world’”.
Server: “…” (didn’t get the message)
Client X:
**Server: **“I feel like adding a message to the chat queue! let’s say, ‘Server rocks your socks!’.”
**Server: **“Hey clients, the chat messages have been updated! Make sure you refresh your GUI to display the updated info! It’s already been automatically replicated to your local copy.”
Clients: “Thanks! Got it! Refreshing GUI now.”
Anyways, I’m not new to network coding but I am new to UE4 networking. I may be totally wrong on my understanding of the architecture and interactions and would like some clarity.