Update nexus wiki content

This commit is contained in:
2026-05-03 05:42:06 +08:00
parent 90f3811b83
commit 111bc65b7b
707 changed files with 32306 additions and 7289 deletions

46
wiki/concepts/RPC.md Normal file
View File

@@ -0,0 +1,46 @@
---
title: "RPC (Remote Procedure Call)"
type: concept
tags: ["unreal-engine", "networking", "client-server"]
sources: ["unreal-multiplayer-architect", "unreal-multiplayer-architect"]
last_updated: 2026-04-30
---
## Aliases
- 远程过程调用
- Server RPC
- Client RPC
- NetMulticast
## 定义
RPC远程过程调用是 UE5 中客户端与服务器之间通信的主要机制,允许在一个网络节点上调用另一个节点上的函数。
## 三种 RPC 类型
### Server RPC
- **方向**: 客户端 → 服务器
- **用途**: 客户端向服务器发送请求(玩家输入、操作命令)
- **要求**: 游戏逻辑 RPC 必须包含 `_Validate()` 实现
- **标记**: `UFUNCTION(Server, Reliable, WithValidation)`
### Client RPC
- **方向**: 服务器 → 特定客户端(拥有该 Actor 的客户端)
- **用途**: 服务器向特定客户端发送消息(私有数据、确认消息)
- **标记**: `UFUNCTION(Client, Reliable)`
### NetMulticast
- **方向**: 服务器 → 所有相关客户端
- **用途**: 服务器向所有客户端广播事件(视觉特效、公共事件)
- **标记**: `UFUNCTION(NetMulticast, Unreliable)`
## 可靠性
- **Reliable**: 保证按序到达,但增加带宽
- **Unreliable**: 尽力发送,可能丢失或乱序
## 安全规范
每个 Server RPC 必须实现 `_Validate()` 函数,拒绝非法输入。缺少验证 = 作弊漏洞。
## 相关概念
- [[Server-Authoritative Model]] — RPC 的使用背景
- [[Actor Replication]] — 与 RPC 配合的状态同步机制
- [[Network Prediction]] — RPC 与客户端预测的协同