Beispiel #1
0
        private void OnDataReceived(byte[] bytes, int size)
        {
            receivedMessageBuffer.WriteBytes(bytes, size);
            byte[] messageBytes = receivedMessageBuffer.ReadMessage();
            while (messageBytes != null)
            {
                ++receivedMessageSeriousIndex;
                Desrialize(messageBytes, out int messageID, out byte seriousIndex, out byte[] dataBytes);

                if (seriousIndex != receivedMessageSeriousIndex)
                {
                    DoDisconnectByError(NetworkDisconnectErrors.ReceivedMessageSerousIndexError);
                    break;
                }
                else
                {
                    netHandler.OnMessageHandler(this, messageID, dataBytes);
                }
            }
        }