In the system, several new separate interfaces are added for the client to send messages to the server.

Q: Why are there these interfaces?

Because the network part of UE has a lot of permission verification related content, sometimes these permission verifications may not be required in our project. Therefore, these interfaces are provided to bypass permission verification and send messages to all ends.

Main API (located in UGlobalEventLibrary)

The system has three built-in EventTags:

The following screenshot shows that Enable Event Listener is called by default at BeginPlay.

Untitled

  1. SendMessageToServer() This is a default interface that uses GameplayTag as the unique ID of the network message and sends the message string to the server. Parameter: Sync to All Client indicates whether the message needs to be synchronized to all clients. If true, the message will be sent to the server and forwarded to all clients; if false, it will only be sent to the server;

    Untitled

  2. SendMessageToServer_ByStruct() This is another form of the default interface, using GameplayTag as the unique ID of the network message to send any type of structure data to the server (this will convert the structure into a string internally, and the client needs to use Json tools to convert the string into a structure for use). Parameter: Sync to All Client indicates whether the message needs to be synchronized to all clients. If true, the message will be sent to the server and forwarded to all clients; if false, it will only be sent to the server;

    Untitled

  3. SendMessageToServer_WithName() This is similar to 1. SendMessageToServer(), the only difference is that GameplayTag is changed to FName, and Name is used to unify the network message ID.

    Untitled