Receive() 개인적인 메소드

private Receive ( int &hostId, int &connectionId, int &channelId, byte buffer, int bufferSize, int &receivedSize, byte &error ) : NetworkEventType
hostId int
connectionId int
channelId int
buffer byte
bufferSize int
receivedSize int
error byte
리턴 NetworkEventType
예제 #1
0
        public static NetworkEventType Receive(out int hostId, out int connectionId, out int channelId, byte[] buffer, int bufferSize, out int receivedSize, out byte error)
        {
            NetworkEventType @event = NetworkTransport.Receive(out hostId, out connectionId, out channelId, buffer, bufferSize, out receivedSize, out error);

            return(BaseReceive(@event, hostId, ref connectionId, ref channelId, buffer, bufferSize, ref receivedSize, ref error));
        }
예제 #2
0
 public NetworkEventType Receive(out int hostId, out int connectionId, out int channelId, byte[] buffer, int bufferSize, out int receivedSize, out byte error)
 {
     return(NetworkTransport.Receive(out hostId, out connectionId, out channelId, buffer, bufferSize, out receivedSize, out error));
 }
예제 #3
0
        public override NetEventType PollEvent(out ulong clientID, out byte channel, out ArraySegment <byte> payload, out float receiveTime)
        {
            NetworkEventType eventType = Unet.Receive(out int hostID, out int connectionID, out int channelID, messageBuffer, messageBuffer.Length, out int receivedSize, out byte error);

            clientID = GetMLAPIClientID((byte)hostID, (ushort)connectionID, false);
            if (channelID > 255 || channelID < 0)
            {
                Debug.LogError("Received invalid Unet channel integer '" + channelID + "'.");
                channel = 255;
            }
            else
            {
                //Convert unet channel to transport channel
                if (!m_TransportChannelLookup.TryGetValue((byte)channelID, out channel))
                {
                    Debug.LogError("Received invalid channel in Unet '" + (byte)channelID + "'.");
                    channel = 255;
                }
            }
            receiveTime = UnityEngine.Time.realtimeSinceStartup;

            NetworkError networkError = (NetworkError)error;

            if (networkError == NetworkError.MessageToLong)
            {
                byte[] tempBuffer;

                if (temporaryBufferReference != null && temporaryBufferReference.IsAlive && ((byte[])temporaryBufferReference.Target).Length >= receivedSize)
                {
                    tempBuffer = (byte[])temporaryBufferReference.Target;
                }
                else
                {
                    tempBuffer = new byte[receivedSize];
                    temporaryBufferReference = new WeakReference(tempBuffer);
                }

                eventType = Unet.Receive(out hostID, out connectionID, out channelID, tempBuffer, tempBuffer.Length, out receivedSize, out error);
                payload   = new ArraySegment <byte>(tempBuffer, 0, receivedSize);
            }
            else
            {
                payload = new ArraySegment <byte>(messageBuffer, 0, receivedSize);
            }

            if (networkError == NetworkError.Timeout)
            {
                // In UNET. Timeouts are not disconnects. We have to translate that here.
                eventType = NetworkEventType.DisconnectEvent;
            }

            // Translate NetworkEventType to NetEventType
            switch (eventType)
            {
            case NetworkEventType.DataEvent:
                return(NetEventType.Data);

            case NetworkEventType.ConnectEvent:
                return(NetEventType.Connect);

            case NetworkEventType.DisconnectEvent:
                return(NetEventType.Disconnect);

            case NetworkEventType.Nothing:
                return(NetEventType.Nothing);

            case NetworkEventType.BroadcastEvent:
                return(NetEventType.Nothing);
            }

            return(NetEventType.Nothing);
        }