UnityEngine.Networking.NetworkTransport.Send C# (CSharp) Method

Send() public static method

public static Send ( int hostId, int connectionId, int channelId, byte buffer, int size, byte &error ) : bool
hostId int
connectionId int
channelId int
buffer byte
size int
error byte
return bool
        public static bool Send(int hostId, int connectionId, int channelId, byte[] buffer, int size, out byte error)
        {
            if (buffer == null)
            {
                throw new NullReferenceException("send buffer is not initialized");
            }
            return SendWrapper(hostId, connectionId, channelId, buffer, size, out error);
        }

Usage Example

Esempio n. 1
0
        public override void Send(ulong clientID, ArraySegment <byte> data, byte channel)
        {
            GetUnetConnectionDetails(clientID, out byte hostID, out ushort connectionID);

            byte[] buffer;

            if (data.Offset > 0)
            {
                // UNET cant handle this, do a copy

                if (messageBuffer.Length >= data.Count)
                {
                    buffer = messageBuffer;
                }
                else
                {
                    if (temporaryBufferReference != null && temporaryBufferReference.IsAlive && ((byte[])temporaryBufferReference.Target).Length >= data.Count)
                    {
                        buffer = (byte[])temporaryBufferReference.Target;
                    }
                    else
                    {
                        buffer = new byte[data.Count];
                        temporaryBufferReference = new WeakReference(buffer);
                    }
                }

                Buffer.BlockCopy(data.Array, data.Offset, buffer, 0, data.Count);
            }
            else
            {
                buffer = data.Array;
            }

            /*RelayTransport.*/
            Unet.Send(hostID, connectionID, m_UnetChannelLookup[channel], buffer, data.Count, out byte error);
        }
All Usage Examples Of UnityEngine.Networking.NetworkTransport::Send