UnityEngine.Networking.ConnectionConfig.AddChannel C# (CSharp) Méthode

AddChannel() public méthode

public AddChannel ( QosType value ) : byte
value QosType Add new channel to configuration.
Résultat byte
        public byte AddChannel(QosType value)
        {
            if (this.m_Channels.Count > 0xff)
            {
                throw new ArgumentOutOfRangeException("Channels Count should be less than 256");
            }
            if (!Enum.IsDefined(typeof(QosType), value))
            {
                throw new ArgumentOutOfRangeException("requested qos type doesn't exist: " + ((int) value));
            }
            ChannelQOS item = new ChannelQOS(value);
            this.m_Channels.Add(item);
            return (byte) (this.m_Channels.Count - 1);
        }

Usage Example

    void Start()
    {
        DontDestroyOnLoad(this);

        //Build the global config
        GlobalConfig clientGlobalConfig = new GlobalConfig();
        clientGlobalConfig.ReactorModel = ReactorModel.FixRateReactor;
        clientGlobalConfig.ThreadAwakeTimeout = 10;

        //Build the channel config
        ConnectionConfig clientConnectionConfig = new ConnectionConfig();
        reliableChannelID = clientConnectionConfig.AddChannel(QosType.ReliableSequenced);
        unreliableChannelID = clientConnectionConfig.AddChannel(QosType.UnreliableSequenced);

        //Create the host topology
        HostTopology hostTopology = new HostTopology(clientConnectionConfig, maxConnections);

        //Initialize the network transport
        NetworkTransport.Init(clientGlobalConfig);

        //Open a socket for the client

        //Make sure the client created the socket successfully

        //Create a byte to store a possible error
        byte possibleError;

        //Connect to the server using
        //int NetworkTransport.Connect(int socketConnectingFrom, string ipAddress, int port, 0, out byte possibleError)
        //Store the ID of the connection in clientServerConnectionID
        NetworkTransport.Connect(clientSocketID, " ", 7777, 0, out possibleError);

        //Display the error (if it did error out)
        Debug.Log("Connection Failed");
    }
All Usage Examples Of UnityEngine.Networking.ConnectionConfig::AddChannel