-
-
Notifications
You must be signed in to change notification settings - Fork 305
Network Message Interpreters
Directory | Previous | Next |
---|---|---|
Directory | Network Messages | Message Pools |
Messages go hand-in-hand with Message Interpreters, for this, you should read up on Network Messages before reviewing this document. That being said, without an interpreter, the Message isn't exactly useful.
When you create any Network Messages you'll notice that the dialog box (seen below) has 3 checkboxes that are directly related to the behavior of the interpreter. When you click on the Create button not only will a message be created, but so will an interpreter. Where the message class will be suffixed with the word Message, the interpreter class will be suffixed with the word Interpreter.
Interpret on server: If this checkbox is enabled, then this message is allowed to be interpreted on the server. This means if a client sends this message to the server, it will execute its behavior. If you do not check this box, then the server will ignore this message if it is received.
Interpret on client: If this checkbox is enabled, then this message is allowed to be interpreted on the client. This means if a server sends this message to the client, it will execute its behavior. If you do not check this box, then the client will ignore this message if it is received.
Singleton Interpreter: This is the default and probably isn't something you would want to turn off unless you are an advanced developer in need of creating new instances of this interpreter for the message to be read by. By turning this on, you will still be able to new up the class (for unit tests and any other reasons), so don't worry.
The message interpreter will be automatically setup based on the check boxes you selected in the dialog box. The most important thing to take note of here is the Interpret
method. Here you will see that there has been a couple of lines auto generated, the more important one being the message being casted to the expected type. From here, you have access to the rest of both your engine and to Forge. You can access Forge through the INetworkMediator netMediator
argument, you can identify who sent the message with the EndPoint sender
argument, and lastly, you can get to your code (if needed) through the netMediator
by accessing the netMediator.EngineProxy
member. If you have just setup Forge without modifications, this will return the ForgeEngineFacade
class (a class you can alter to what you need or completely replace). Something you'll probably want to do is do some further reading on the Engine Facade.
At this point, you have everything you need to know what message came in, who sent the message, how to reply to the message (if needed) using the netMediator, and access to the rest of your game code through the engine facade. For some examples of how to use the message interpreters, check out the example docs for things like Chat Example, Spawning Example, and Complex Example.
The template system in Forge Alloy is much less a system and much more a file selection and modifying it's contents. The file templates can be located in the Assets/ForgeNetworking/Editor/Resources/ForgeNetworking/Templates
folder. As it relates to Messages, you'll see a MessageInterpreterTemplate.txt file and a MessageInterpreterTemplateSingleton.txt. Based on if you select for the interpreter to be a singleton or not will select which of the two templates to use.
Directory | Previous | Next |
---|---|---|
Directory | Network Messages | Message Pools |
Getting Started
Network Contract Wizard (NCW)
Remote Procedure Calls (RPCs)
Unity Integration
Basic Network Samples
Scene Navigation
Master Server
Netcoding Design Patterns
Troubleshooting
Miscellaneous
-
Connection Cycle Events
-
Rewinding
-
Network Logging
-
Working with Multiple Sockets
-
Modify Master and Standalone servers
-
NAT Hole Punching
-
UDP LAN Discovery
-
Offline Mode
-
Ping Pong
-
Lobby System
-
Upgrading Forge Remastered to Develop branch or different version
-
Forge Networking Classic to Remastered Migration Guide
-
Script to easily use Forge Networking from sources
-
Run Two Unity Instances with Shared Assets for Easiest Dedicated Client Workflow