KLF.KLFManager.handleInteropMessage C# (CSharp) Method

handleInteropMessage() private method

private handleInteropMessage ( KLFCommon id, byte data ) : void
id KLFCommon
data byte
return void
        private void handleInteropMessage(KLFCommon.ClientInteropMessageID id, byte[] data)
        {
            switch (id)
            {
                case KLFCommon.ClientInteropMessageID.CHAT_RECEIVE:

                    if (data != null)
                    {
                        KLFChatDisplay.enqueueChatLine(encoder.GetString(data));
                    }

                    break;

                case KLFCommon.ClientInteropMessageID.CLIENT_DATA:

                    if (data != null && data.Length > 9)
                    {
                        //Read inactive vessels per update count
                        inactiveVesselsPerUpdate = data[0];

                        //Read screenshot height
                        KLFScreenshotDisplay.screenshotSettings.maxHeight = KLFCommon.intFromBytes(data, 1);

                        updateInterval = ((float)KLFCommon.intFromBytes(data, 5))/1000.0f;

                        //Read username
                        playerName = encoder.GetString(data, 9, data.Length - 9);
                    }

                    break;

                case KLFCommon.ClientInteropMessageID.PLUGIN_UPDATE:
                    if (data != null)
                    {
                        //De-serialize and handle the update
                        handleUpdate(KSP.IO.IOUtils.DeserializeFromBinary(data));
                    }
                    break;

                case KLFCommon.ClientInteropMessageID.SCREENSHOT_RECEIVE:
                    if (data != null)
                    {
                        Debug.Log("Received screenshot");
                        KLFScreenshotDisplay.screenshot.setFromByteArray(data);

                        if (KLFScreenshotDisplay.screenshot.image.Length <= KLFScreenshotDisplay.screenshotSettings.maxNumBytes)
                        {
                            if (KLFScreenshotDisplay.texture == null)
                                KLFScreenshotDisplay.texture = new Texture2D(4, 4, TextureFormat.RGB24, false, true);

                            if (KLFScreenshotDisplay.texture.LoadImage(KLFScreenshotDisplay.screenshot.image))
                            {
                                KLFScreenshotDisplay.texture.Apply();

                                //Make sure the screenshot texture does not exceed the size limits
                                if (KLFScreenshotDisplay.texture.width > KLFScreenshotDisplay.screenshotSettings.maxWidth
                                    || KLFScreenshotDisplay.texture.height > KLFScreenshotDisplay.screenshotSettings.maxHeight)
                                {
                                    KLFScreenshotDisplay.screenshot.clear();
                                }
                            }
                            else
                            {
                                KLFScreenshotDisplay.screenshot.clear();
                            }

                            KLFScreenshotDisplay.screenshot.image = null;
                        }
                    }
                    break;
            }
        }