public byte AddChannel (Networking.QosType value);

Parámetros

valueAdd new channel to configuration.

Valor de retorno

byte Channel id, user can use this id to send message via this channel.

Descripción

Adds a new channel to the configuration and returns the unique id of that channel.

Channels are logical delimiters of traffic between peers. Every time you send data to a peer, you should use two ids: connection id and channel id. Channels are not only logically separate traffic but could each be configured with a different quality of service (QOS). In the example below, a configuration is created containing two channels with Unreliable and Reliable QOS types. This configuration is then used for sending data.

using UnityEngine;
using UnityEngine.Networking;

public class ExampleScript : NetworkBehaviour { void Start() { ConnectionConfig myConfig = new ConnectionConfig(); int reliableChannelId = myConfig.AddChannel(QosType.Unreliable); int unreliableChannelId = myConfig.AddChannel(QosType.Reliable);

//......

//NetworkTransport.Send(hostId, connection, reliableChannelId, data, data.Length, out error); //sends data via Reliable channel } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961