Tuesday, November 20th, 2018
UDP
TCP
Most RT games: Reliable UDP
For info if you develop alt-ctrl games
RS232
SPI
I2C
CAN
Fairness
Determinism
Without
With
Fun
Flow
No frustration
+ Central authority
- Heavy load
+ Distribute the load
- More complex to synchronize
For instance:
Host for gameplay events
P2P for chat
"Around the game"
No RT requirement
TCP / HTTP are relevant
Requires a database
Requires a profanity checker
Requires a storage space for the picture
With a matching algorithm
Requires a profile service
Transforming objects to/from memory buffers
Indirections (pointers)
Endianness
Optimisations, perhaps
Lack of support (some RTTI though)
Usually: custom solutions
struct CharacterProfile
{
string name;
int level;
void Serialize(Serializer &serializer);
};
void CharacterProfile::Serialize(Serializer &serializer)
{
serializer << name;
serializer << level;
}
UCLASS()
class GAME_API UCharacterProfile : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Switch Variables");
string name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Switch Variables")
int level;
};
Rely on the Unreal Header Tool
[Serializable]
public class CharacterProfile
{
public string name;
public int level;
}
public void Load()
{
CharacterProfile profile;
BinaryFormatter formatter = new BinaryFormatter();
using (FileStream stream = File.OpenRead(filePath))
{
profile = formatter.Deserialize(stream) as CharacterProfile;
}
}
(e.g. when writing custom editors)
void OnEnable()
{
name = serializedObject.FindProperty("name").stringValue;
level = serializedObject.FindProperty("level").intValue;
}
Example: JSON
{
"characterProfile": {
"name": "John Doe",
"level": 42
}
}
VehicleUnit unit{ position: {4, 7}, speed: 10 };
game.Add(unit);
MoveCommand cmd{ target: {5, 2} };
game.Execute(cmd);
EXPECT_EQ({4, 7}, unit.position);
game.Update(1.0f);
EXPECT_EQ({5, 2}, unit.position);
get('/profile/johndoe')
.expect(404);
post('/profile/', ...)
.expect(201);
get('/profile/johndoe')
.expect(200);
put('/profile/johndoe', ...)
.expect(204);
get('/profile/johndoe')
.expect(200);
delete('/profile/johndoe')
.expect(204);
get('/profile/johndoe')
.expect(404);
Rule #1: Don't do it
Rule #2 (for experts only): Don't do it yet
Architecture
Modelisation
Example: sending a number (64 bits)
Send the full value (64 bits)
Add one bit to tell whether the value is zero (1 or 65 bits)
Only send the less significant bits (from 6 to 70 bits)
float: do not send least significant mantissa numbers
normalized vec3: only send two components
rotation mat33: transform to a quaternion, only send three components
Do not wait for the response
Network camera
P2P: better ownership distribution
Being able to spread the load
No Single Points of Failure
Redundancy (load balancers, database clusters...)
Being able to scale
Deployment
Being able to deploy several versions
Development, Tests, Production...
How to switch?
Useful for debugging the servers...
From metrics to alerts
Firewall
HTTPS
Authentication token
Architecture
Modelisation
Asynchronous
Logs & metrics
Logical thinking
Linux / terminal
Web development
Gaffer on Games | Game Networking
1500 Archers on a 28.8: Network Programming in Age of Empires and Beyond