文档

Development

User Acquisition

Monetization

工业

Multiplayer Services SDK

All Services

Multiplayer Services SDK

此页面不支持所选语言。
Multiplayer
​
​
Multiplayer Services SDK
  • Overview
  • Get started
  • Use multiplayer sessions
  • Manage sessions
  • Connect players through a relay
  • Networking
    • Ports and protocols
    • Locations and regions
    • Quality of service
    • Scaling
    • DTLS encryption
    • Advanced configuration
      • Relay allocation service
      • Relay allocating, binding, and joining
      • Relay vs Lobby
      • Relay message protocol
      • Connection flow
      • Relay REST API
      • Manually configure Relay with Netcode for GameObjects
  • Matchmaking
  • Monitor and debug sessions
  • Tutorials
  • Reference
  1. Multiplayer Services SDK

Relay allocating, binding, and joining

Understand the three distinct steps for establishing a Relay connection between players.
阅读时间2 分钟
最后更新于 2 个月前

An allocation is a request to the Allocations service from the host player to reserve space on a Relay server for the host plus the number of players the host is expecting to join their game (indicated with the
max_players
field in the
/allocate request
). After a player joins the host player’s allocation, they receive a unique allocation ID, and Relay considers the player allocated.
Allocating, binding, and joining are three distinct concepts in the Relay connection flow.
注意
Binding, and other interactions done through a Relay server, are handled using a networking solution such as UTP or NGO. NGO is higher level and uses UTP under the hood.

Allocating

Allocating is when a host player tells the Allocations service about their intent to connect to a Relay server, and the Allocations service reserves slots on a Relay server. When the Allocations service reserves slots on a Relay server, it prepares the Relay server for players to bind (establish a network connection). The number of slots depends on the maximum number of connections specified in the allocation request.
Check out the following steps in the connection flow:
  • The host player requests an allocation
  • The Allocations service selects a Relay server
  • The Allocations service sends the connection data to the host player

Binding

Binding is when the player establishes a connection with the Relay server that the Allocations service reserved for the player during the allocating process. After the player completes the binding process, the Relay server can discover the player’s IP address and exchange packets.
注意
The host player and joining players must bind to the Relay server before connecting to each other.
A
BIND
is a specific message sent via the Relay protocol from the game client to the Relay server to establish its connection to the Relay server.
注意
You typically send
BIND
messages after calling the allocate and join APIs, which retrieve the Relay server’s destination address for use with the
BIND
message.
Check out the following steps in the connection flow:
  • The host player binds to the Relay server
  • The joining player binds to the Relay server

Joining

Joining is when a joining player joins the host player’s allocation on a Relay server. After the joining player completes the joining process, they can exchange messages with the host player. Allocating and joining are similar processes. The primary difference is that the join API response has the host connection data.
注意
A join is when a joining player (a non-host player) client joins the host client’s session. Under the hood, it’s another allocate call to the Relay service.
Check out the following steps in the connection flow:
  • The joining players use the join code
  • The Allocations service sends connection data to the joining player
  • The joining player sends connection request

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • Allocating

    • Binding

    • Joining


报告此页面的问题
​
​