Legacy Documentation: Version 2017.2 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ConnectionConfig.AddChannel

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public method AddChannel(value: Networking.QosType): byte;
public byte AddChannel(Networking.QosType value);

Parameters

value Add new channel to configuration.

Returns

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

Description

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.

no example available in JavaScript
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 } }

Did you find this page useful? Please give it a rating: