此类定义两个对等方之间的连接的参数,此定义包含各种超时和大小以及通道配置。
此类的实例可用于配置 NetworkServer 和 NetworkClient 类。这样,ConnectionConfig 中的设置便可应用到这些对象所拥有的 NetworkConnection 的传输层连接。
NetworkManager 有一个 ConnectionConfig 对象,可用于配置该对象创建的服务器和客户端。
网络系统的高级组件使用的默认通道连接配置为:
* 通道 0 - 经过排序的可靠通道
* 通道 1 - 不可靠通道。
在 Editor 中,可以使用适用于 NetworkManager 的 Inspector UI 修改此 ConnectionConfig 实例的一些属性。
重要信息:ConnectionConfig 的一些参数应与所连接对等方的参数完全相同。如果它们不相同,则在尝试建立连接时会收到 CRCMismatch 错误。
这些参数为:
- PacketSize
- FragmentSize
- ResendTimeout
- DisconnectTimeout
- ConnectTimeout
- PingTimeout
- ReducedPingTimeout
- AllCostTimeout
- IsAckLong
- UsePlatformSpecificProtocols。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.